n = input() l = list(map(int, input().split())) print(max([_ for _ in set(l) if l.count(_)>1]))