#!/bin/python3 import sys from collections import Counter n = int(input().strip()) types = list(map(int, input().strip().split(' '))) # your code goes here freq = Counter(types) maxFreq = max(freq.values()) print(min([id for id in freq if freq[id] == maxFreq]))