#!/bin/python3 import sys n = int(input().strip()) types = list(map(int, input().strip().split(' '))) count = [0 for _ in range(5)] max = 0 maxobj = 0; for i in types: count[i-1] += 1 if count[i-1] > max: maxobj = i max = count[i-1] if count[i-1] == max: if i < maxobj: maxobj = i print(maxobj) # your code goes here