n = input() score = [0 for i in range(n + 1)] key = map(int, raw_input().split()) for i in key: score[i] += 1 print max([i for i, x in enumerate(score) if x == max(score)])