#!/bin/python3 import sys from collections import* n = int(input().strip()) types = list(map(int, input().strip().split(' '))) # your code goes here count = Counter(types) max_count,b_id=0,-1 for i in count: if count[i]>max_count: max_count=count[i] b_id=i if count[i]==max_count: if b_id>i: b_id=i print(b_id)