#!/bin/python3 import sys n = int(input().strip()) types = list(map(int, input().strip().split(' '))) counter = {} for x in types: counter[x] = counter.get(x, 0) + 1 s = sorted(counter.items(), key=lambda x: x[1], reverse=True) top_value = s[0][1] v = list(filter((lambda x: x[1] == top_value), s))[0][0] print(v)