#!/bin/python import sys n = int(raw_input().strip()) types = map(int, raw_input().strip().split(' ')) items = list(set(types)) k = {} high = [] highest = 0; for item in items: count = list(types).count(item) if count > highest: highest = count high = [item] elif(highest == count): high.append(item) print min(high)