def main(): num = int(input()) levels = list(map(int, input().split())) max_count = 1 ans_level = 0 for i in set(levels): count = levels.count(i) #print("count", count) if count > max_count: max_count = count ans_level = i elif count == max_count: if i > ans_level: ans_level = i print(ans_level) if __name__ == '__main__': main()