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