#!/bin/python3 import sys from collections import defaultdict n = int(input().strip()) types = list(map(int, input().strip().split(' '))) # your code goes here A = defaultdict(int) for k in types: A[k] += 1 max = max(A.values()) B = sorted(A.items(), key = lambda x : x[1], reverse=True) C = [x[0] for x in B if x[1] == max] C.sort() print(C[0])