n = int(input()) s = [0]*(n+1) for i in list(map(int,input().split())): s[i] += 1 if s.count(max(s)) > 1: s[s.index(max(s))] -= 1 print(s.index(max(s)))