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]; Map map = new HashMap(); for(int types_i=0; types_i < n; types_i++){ types[types_i] = in.nextInt(); if(!map.containsKey(types[types_i])){ map.put(types[types_i], 1); } else if(map.containsKey(types[types_i])){ map.put(types[types_i],map.get(types[types_i]) + 1); } } // your code goes here int maxValue = Collections.max(map.values()); System.out.println(getKeyFromValue(map,maxValue)); } public static Object getKeyFromValue(Map hm, Object value) { for (Object o : hm.keySet()) { if (hm.get(o).equals(value)) { return o; } } return null; } }