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]; for(int types_i=0; types_i < n; types_i++){ types[types_i] = in.nextInt(); } // your code goes here Map map = new HashMap(); int maxCount = 0; for(int i = 0; i < types.length; i++) { if(map.containsKey(types[i])) { Integer c = map.get(types[i]); c++; map.put(types[i], c); } else { map.put(types[i], 1); } } int type = 0; for(Map.Entry entry : map.entrySet()) { if(entry.getValue() > maxCount) { maxCount = entry.getValue(); type = entry.getKey(); } else if(entry.getValue() == maxCount) { if(type >= entry.getKey()) { type = entry.getKey(); } } } System.out.println(type); } }