import sys n = int(input().strip()) types = map(int,input().strip().split(' ')) # your code goes here from collections import Counter c=Counter(types) print(sorted(list(c.items()),key=lambda x: (-x[1],x[0]))[0][0])