#!/bin/python import sys def cmp(x, y): if x[0] == y[0]: if x[1] > y[1]: return -1 else: return 1 elif x[0] < y[0]: return -1 else: return 1 n = int(raw_input().strip()) types = map(int, raw_input().strip().split(' ')) # your code goes here counts = {} for t in types: try: counts[t] += 1 except KeyError: counts[t] = 1 best = sorted([ (n, t) for t, n in counts.iteritems() ], cmp=cmp)[-1] print best[1]