#!/bin/python import sys n = int(raw_input().strip()) types = map(int, raw_input().strip().split(' ')) # your code goes here count = {} for key in types: count[key] = count.get(key, 0) + 1 mx = max(count.values()) print min([key for key, value in count.items() if value == mx])