#!/bin/python3

import math
import os
import random
import re
import sys

# Complete the migratoryBirds function below.
def migratoryBirds(arr):
    dup=[]
    occurrences=[]
    for i in arr:
        if i not in dup:
            dup.append(i)
    for i in dup:
        occurrences.append(arr.count(i))
    a=max(occurrences)
    maxi=[]
    for i in range(len(occurrences)):
        if a==occurrences[i]:
            maxi.append(dup[i])
    
    return min(maxi)

if __name__ == '__main__':
    fptr = open(os.environ['OUTPUT_PATH'], 'w')

    arr_count = int(input().strip())

    arr = list(map(int, input().rstrip().split()))

    result = migratoryBirds(arr)

    fptr.write(str(result) + '\n')

    fptr.close()
