from collections import Counter n = int(raw_input()) types = map(int, raw_input().split()) type_counter = Counter(types) max_value = 0 for k, v in type_counter.iteritems(): max_value = v if v > max_value else max_value maxed_types = [] for k, v in type_counter.iteritems(): if v == max_value: maxed_types.append(k) print min(maxed_types)