#!/bin/python3 import collections as col import sys n = int(input().strip()) types = list(map(int, input().strip().split())) ctr = col.Counter(types) mc = ctr.most_common() minType = mc[0][0] maxCnt = mc[0][1] i = 1 while i < 5 and mc[i][1] == maxCnt: if mc[i][0] < minType: minType = mc[i][0] i += 1 print(minType)