#!/bin/python import sys n = int(raw_input().strip()) types = map(int, raw_input().strip().split(' ')) max_count = -1 type_with_max = None type_map = dict() for i in range(n): if types[i] in type_map.keys(): type_map[types[i]] = type_map[types[i]] + 1 else: type_map[types[i]] = 1 if type_map[types[i]] > max_count or (type_map[types[i]] == max_count and types[i] < type_with_max): max_count = type_map[types[i]] type_with_max = types[i] print type_with_max # your code goes here