import collections N = int(input()) L = [int(i) for i in input().strip().split(' ')] c = collections.Counter(L) print('{}'.format(max([n for n, i in zip(c.keys(), c.values()) if i == max(c.values())])))