N = int(input()) L = list(map(int, input().split())) S = set(L) L2 = [[s, L.count(s)] for s in S] L2 = sorted(L2, reverse=True, key=lambda X: (X[1], X[0])) print(L2[0][0])