#!/bin/python3 import sys n = int(input().strip()) types = list(map(int, input().strip().split(' '))) # your code goes here id,max_count = 0,0 for type in set(types): type_count = types.count(type) if max_count < type_count: id,max_count = type,type_count elif max_count == type_count: id = min(id,type) print(id)