class Problem0079: def solve(this): n = int(input()) l = list(map(int, input().split())) res = {} for v in l: res[v] = res.get(v,0) + 1 ans = 0 cnt = 0 for (k,v) in res.items(): if cnt <= v: ans = max(ans, k) cnt = v print(ans) if __name__ == "__main__": problem = Problem0079() problem.solve()