#!/bin/python3

import sys


n = int(input().strip())
types = list(map(int, input().strip().split()))

number = 0
for i in set(types):
    if types.count(i) > number:
        number = types.count(i)
        f = i

l = []
for i in set(types):
    if types.count(i) == number:
        l += [i]
        
print(min(l))