import collections N = int(input()) L = list(map(int, input().split())) c = collections.Counter(L).most_common() x, n = c[0] for i in range(1, len(c)): if n != c[i][1]: break x = max(x, c[i][0]) print(x)