N=int(input()) L=sorted(map(int,input().split())) from collections import Counter C=Counter(L) MAX=max(C.values()) ANS=-1 for l in L: if C[l]==MAX: ANS=l print(ANS)