N = int(input()) L = list(map(int, input().split())) d = {} for i in L: if not i in d: d[i] = 1 else: d[i] += 1 x = max(d.values()) y = [k for k, v in d.items() if v == x] print(max(y))