import collections N = input() L = [int(s) for s in input().split()] c = collections.Counter(L) c = sorted(c.items(), key=lambda x: x[0], reverse=True) print(c[0][0])