from collections import Counter N=int(input()) L=sorted(list(Counter(list(map(int,input().split()))).items()),key=lambda x:x[1]) cnt=L[-1][1] print(max(i for i,j in L if j==cnt))