#!/usr/bin/python from collections import Counter n = int(raw_input()) L = map(int, raw_input().split()) cnt = Counter(L) haa = max(cnt.values()) res = max(k for k, v in cnt.items() if v==haa) print res