N = int(input()) L = map(int, input().split()) NL = [0] * N for i in L: NL[i] += 1 ans = [i for i in range(N) if NL[i] == max(NL)] print(max(ans))