N = int(input()) L = list(map(int, input().split())) M = {} for Li in L: if Li in M.keys(): M[Li]+=1 else: M[Li] = 1 M_sorted = sorted(M.items(), key=lambda x: x[1]) M_sorted = sorted(M_sorted, key=lambda x: x[0]) print(M_sorted[-1][0])