from collections import Counter from functools import cmp_to_key N = int(input()) L = list(map(int, input().split())) def cmp(a, b): x = a[1] - b[1] if x == 0: return a[0] - b[0] return x xs = sorted(Counter(L).most_common(), key=cmp_to_key(cmp)) ans = xs[-1][0] print(ans)