#!/bin/python3 import sys d = {} n = int(input().strip()) types = list(map(int, input().strip().split(' '))) for x in types: if x not in d: d[x] = types.count(x) max_val = sorted([key for key,value in d.items() if value==max(d.values())])[0] print(max_val)