n=int(input())
a=list(map(int, input().split()))
old_a=a
b=[]
a.sort()
count=1
for i in range(1,n):
if a[i]==a[i-1]:
count=count+1
else:
b.append(count)
count=1
if count==n:
b.append(count)
max=max(b)
sum=0
for item in b:
if item<max:
sum=sum+item
else:
break
sum=sum+max-1
print(old_a[sum])