#!/bin/python import sys n = int(raw_input().strip()) types = map(int, raw_input().strip().split(' ')) flock_type = {} for type in types: flock_type[type] = flock_type.get(type, 0) + 1 values = flock_type.items() lst = [] for key, value in values: lst.append((value , key)) lst.sort(reverse=True) until = 0 max = None min = None for i in lst: if max is None or max <= i[0]: max = i[0] until += 1 #Print the type number of the most common bird if until == 1: print lst[0][1] #if two or more types of birds are equally common, choose the type with the smallest ID number. else: for i in lst[:until]: if min is None or min >= i[1]: min = i[1] print min #lst[:until]