import java.io.*; import java.util.*; import java.text.*; import java.math.*; import java.util.regex.*; public class Solution { public static void main(String[] args) { Scanner in = new Scanner(System.in); int n = in.nextInt(); TreeMap map = new TreeMap<>( Collections.reverseOrder()); for(int types_i=0; types_i < n; types_i++){ int val = in.nextInt(); if(map.containsKey(val)){ Integer tempCnt = map.get(val); tempCnt++; map.put(val, tempCnt); }else{ map.put(val, 1); } } int max =0; int common = 0; for(Integer key:map.keySet()){ Integer val = map.get(key); if(max <= val){ max=val; common = key; } } System.out.println(common); } }