#!/bin/python3 import sys from collections import Counter n = int(input().strip()) types = list(map(int, input().strip().split(' '))) # your code goes here t = Counter(types) maximum = t.most_common()[0][1] print(min([x for (x,y) in t.most_common() if y==maximum]))