#!/bin/python3 import sys n = int(input().strip()) types = list(map(int, input().strip().split(' '))) # your code goes here birds = {} most_common_type = None most_common_val = 0 for i in types: if i in birds: birds[i] = birds[i]+1 else: birds[i] = 1 if most_common_type == None: most_common_type = i most_common_val = birds[i] else: if birds[i] > most_common_val: most_common_val = birds[i] most_common_type = i elif most_common_val == birds[i]: if i < most_common_type: most_common_type = i most_common_val = birds[i] print(most_common_type)