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]; HashMap map = new HashMap(); map.put(1,0); map.put(2,0); map.put(3,0); map.put(4,0); map.put(5,0); for(int types_i=0; types_i < n; types_i++){ types[types_i] = in.nextInt(); map.put(types[types_i],map.get(types[types_i])+1); } int max = Integer.MIN_VALUE; int result = 0; int maxValueInMap=(Collections.max(map.values())); // This will return max value in the Hashmap for (Map.Entry entry : map.entrySet()) { // Itrate through hashmap if (entry.getValue()==maxValueInMap) { System.out.println(entry.getKey()); return;// Print the key with max value } } } }