i=input i() L=list(map(int,i().split())) print(max(set(L),key=lambda x:(L.count(x), x)))