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