input() l = list(map(int, input().split())) d = {} for i in l: if not i in d: d[i] = 1 else: d[i] += 1 l = [] for i in d.items(): if i[1] == max(d.values()): l.append(i[0]) print(max(l))