# -*- coding: utf-8 -*- from collections import Counter N = int(input()) a = Counter(list(map(int, input().split()))) ans = -1 mx = -1 for key, num in a.items(): if mx <= num: mx = num if ans < key: ans = key print(ans)