#!/bin/python import sys n = int(raw_input().strip()) types = map(int, raw_input().strip().split(' ')) # your code goes here from collections import Counter d=Counter(types) print sorted([(key, d[key]) for key in d],key=lambda x: (-x[1],x[0]) )[0][0]