#!/bin/python import sys n = int(raw_input().strip()) types = map(int, raw_input().strip().split(' ')) # your code goes here count = {} for t in types: if t not in count.keys(): count[t] = 0 count[t] += 1 current_max = 0 current_key = 200001 for key in count.keys(): if count[key] > current_max: current_max = count[key] current_key = key elif count[key] == current_max and current_key > key: current_max = count[key] current_key = key print current_key