# coding: utf-8 from collections import Counter n = int(input()) t = list(map(int, input().split(" "))) res = 0 c = Counter(t) print(sorted(c.items(), key=lambda x: -x[0])[0][0])