#!/usr/bin/python from collections import Counter, namedtuple Item = namedtuple('Item', 'level, users') N = int(raw_input()) L = map(int, raw_input().split()) counter = Counter(L) hamark = max(counter.values()) filtered = filter(lambda x: x.users==hamark, (Item(k, v) for k, v in counter.items())) print max(filtered, key=lambda x:x.level).level