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 count=0; for (int type : types){ if(map.get(type)!=null){ count=map.get(type); map.put(type, ++count); } else { map.put(type,1); } } Set keys = map.keySet(); int maxCount=0; int typeBird=0; for(int key : keys) { count = map.get(key); if(count>maxCount) { maxCount = count; typeBird = key; } else if(count == maxCount) { if(typeBird>key) { typeBird = key; } } } System.out.println(typeBird); } }