import sys from collections import Counter n = int(input().strip()) types = list(map(int, input().strip().split(' '))) c = Counter(types) x = [i for i in c if c[i] == max(c.values())] x.sort() print(x[0])