#!/bin/python3 import sys from collections import Counter as C n = int(input().strip()) # Count all itesm types = C(list(map(int, input().strip().split(' ')))) # Get highest value best = types.most_common(1)[0] # Check against every other value for bird_type in types.most_common(): if bird_type[1] < best[1]: break elif bird_type[0] < best[0]: best = bird_type print(best[0])