n = int(input())
lst = list(map(int, input().split()))
s = set(lst)
dic = {}
for i in s:
dic[i] = 0
for i in lst:
dic[i] += 1
res = 0
cnt = 0
for i in dic:
if dic[i] > cnt:
res = i
cnt = dic[i]
elif dic[i] == cnt and i < res:
res = i
print(res)