n = input() score = [0 for i in range(n + 1)] key = map(int, raw_input().split()) for i in key: score[i] += 1 maxes = [-1, -1] for i in range(1, len(score)): if maxes[0] <= score[i]: maxes[0], maxes[1] = score[i], i print maxes[1]