#!/bin/python import sys import collections n = int(raw_input().strip()) items = map(int, raw_input().strip().split(' ')) # your code goes here if len(items): type_map = collections.defaultdict(int) for ty in items: type_map[ty] += 1 ma = 0 ma_k = 0 for key, val in type_map.iteritems(): if not ma: ma = val ma_k = key continue if val > ma: ma_k = key ma = val elif val == ma: mk_k = min(ma_k, key) print ma_k