#!/bin/python import sys n = int(raw_input().strip()) types = map(int, raw_input().strip().split(' ')) # your code goes here dict = {} for type in types: if dict.has_key(type): dict[type] += 1 else: dict[type] = 1 max_k, max_v = 0, 0 for k, v in dict.iteritems(): if v > max_v: max_v = v max_k = k elif v == max_v and k < max_k: max_k = k print max_k