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(); int[] types = new int[n]; TreeMap map=new TreeMap<>(); for(int types_i=0; types_i < n; types_i++){ int type=in.nextInt(); types[types_i] = type; if(map.containsKey(type)){ int value=(Integer)map.get(type); map.put(type,++value); }else{ map.put(type,1); } } int maxTypeCount=0,maxCountType=0; for(Map.Entry entry : map.entrySet()){ if((Integer)entry.getValue()>maxTypeCount){ maxTypeCount=(Integer)entry.getValue(); maxCountType=(Integer)entry.getKey(); } } System.out.println(maxCountType); } }