#!/bin/python3 import sys from collections import Counter n = int(input().strip()) types = list(map(int, input().strip().split(' '))) # your code goes here c = Counter(types) modal_val = max(c.values()) mode_lst = {k:v for (k,v) in c.items() if v == modal_val} print(min(mode_lst.keys()))