from collections import Counter N, *L = map(int, open(0).read().split()) C = list(Counter(L).items()) C.sort(key=lambda x: -x[0]) C.sort(key=lambda x: -x[1]) print(C[0][0])