N = input() L = map(int,raw_input().split()) m = 0 v = 0 for s in set(L): if m < L.count(s): v = s m = L.count(s) elif m == L.count(s) and v < s: v = s print v