from collections import Counter n=int(input()) ls=[int(i) for i in input().split()] cls=[] #リストの値をカウント cnt=Counter(ls) #カウント最大数を取得 max_v=max(cnt.values()) #カウント最大数の値を追加 for value,count in cnt.items(): if max_v==count: cls.append(value) #最大値を出力 print(max(cls))