#!/bin/python import sys def birds_frequencies(birds): freq = {} for b in birds: if b in freq: freq[b] += 1 else: freq[b] = 1 return freq def most_frequent(freq): maxi = len(freq) + 1; maxv = -1 for i in freq: if freq[i] > maxv or (freq[i] == maxv and i < maxi): maxi = i maxv = freq[i] return maxi n = int(raw_input().strip()) types = map(int, raw_input().strip().split(' ')) # your code goes here print most_frequent(birds_frequencies(types))