from collections import Counter input();print max(Counter(map(int,raw_input().split())).items(),key=lambda x:(x[1],x[0]))[0]