N = int(input()) l = list(map(int, input().split())) current = 0 currentCount = 0 l.sort() for i in l: if i > current: if l.count(i) >= currentCount and i > current: currentCount = l.count(i) current = i print(current)