#!/bin/python3 from collections import Counter if __name__ == '__main__': input() # Ignore the first line # Count each different number in the second line c = Counter(int(i) for i in input().split()) result = max(c.keys(), key=lambda x: (c[x], -x)) print(result)