#!/bin/python3 import sys from collections import Counter n = int(input().strip()) types = list(map(int, input().strip().split(' '))) # your code goes here count=Counter(types) high=max(count.values()) common=min(list(i for i,j in count.items() if j==high)) print(common)