#!/bin/python import sys from collections import Counter n = int(raw_input().strip()) types = map(int, raw_input().strip().split(' ')) # your code goes here birds = Counter(types) top_number = birds.most_common(1)[0][1] print sorted([k for k, v in birds.iteritems() if v == top_number])[0]