#!/bin/python import sys n = int(raw_input().strip()) types = map(int, raw_input().strip().split(' ')) # your code goes here count = {} for i in types: count[i] = count.get(i, 0) + 1 list_items = sorted(count.items(), key = lambda t: (t[1], -t[0]), reverse = True) print list_items[0][0]