from collections import * input() ll=list(map(int,input().split())) ll=Counter(ll) for k,v in sorted(ll.items(),key=lambda x:(x[1],x[0]),reverse=True): print(k) break