from collections import Counter n = int(input()) A = list(map(int, input().split())) mx, ind = 0, 0 D = Counter(A) for d in sorted(D.keys()): if D[d] >= mx: mx, ind = D[d], d print(ind)