#!/bin/python3 import collections import sys n = int(input().strip()) types = list(map(int, input().strip().split(' '))) # your code goes here types = collections.Counter(types) maxBird = max(types.values()) lowMost = [x for x,y in types.items() if y == maxBird] lowMost = min(lowMost) print(lowMost)