#!/bin/python import sys n = int(raw_input().strip()) types = map(int, raw_input().strip().split(' ')) # your code goes here def birds(x): dic = dict() maxNum = -1 stack = list() for i in xrange(len(x)): if not x[i] in dic.keys(): dic[x[i]] = 1 else: dic[x[i]] += 1 if dic[x[i]] > maxNum: stack = list([x[i]]) maxNum = dic[x[i]] elif dic[x[i]] == maxNum: stack.append(x[i]) return sorted(stack)[0] print birds(types)