n = input() cnt = [0] * 7 mode = 0 L = [int(x) for x in input().split()] for li in L: cnt[li] += 1 if cnt[li] >= cnt[mode] and li >= mode: mode = li print(mode)