# -*- coding:utf-8 -*- import collections if __name__ == "__main__": n = input() l = map(int,raw_input().split()) count = collections.Counter(l) max = -1 ans = 0 for i,j in count.most_common(): if max == -1: max = j if max > j: break elif max == j and ans < i: ans = i print ans