#!/bin/python3 import sys n = int(input().strip()) types = list(map(int, input().strip().split(' '))) # your code goes here # build dictionary types_dict = {} for bird in types: types_dict[bird] = types_dict.get(bird, 0) + 1 max_id, max_count = (None, -1) # find most frequent id for id, count in types_dict.items(): if count > max_count: max_id = id max_count = count elif count == max_count and id < max_id: max_id = id max_count = count print(max_id)