from collections import Counter n = int(input().strip()) types = list(map(int, input().strip().split(' '))) d = {}.fromkeys(types,0) c = 0 t = 0 for x in types: d[x] += 1 if (d[x]>c) or ((d[x]==c) and (x