from collections import Counter def main(): N = int(input()) L = list(map(int, input().split())) l_counter = Counter(L) sorted_list = sorted( range(1, N+1), key=lambda num: (l_counter[num], num), reverse=True) print(sorted_list[0]) if __name__ == "__main__": main()