#!/bin/python3 import sys n = int(input().strip()) types = list(map(int, input().strip().split(' '))) counts = {} for bird in types: if bird not in counts: counts[bird] = 1 else: counts[bird] += 1 highest_count = max(counts.values()) lowest_ID = None for key in counts: if counts[key] == highest_count: if lowest_ID == None or int(key) < lowest_ID: lowest_ID = int(key) print(lowest_ID)