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