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 int numberOf1s = 0; int numberOf2s = 0; int numberOf3s = 0; int numberOf4s = 0; int numberOf5s = 0; for (int i = 0; i < n; i++) { switch(types[i]) { case 1 : numberOf1s++; break; case 2 : numberOf2s++; break; case 3 : numberOf3s++; break; case 4 : numberOf4s++; break; case 5 : numberOf5s++; break; } } // We have the amount of each bird. Now we need to compare them Map birdIndex = new HashMap(); // Index birds birdIndex.put(1, numberOf1s); birdIndex.put(2, numberOf2s); birdIndex.put(3, numberOf3s); birdIndex.put(4, numberOf4s); birdIndex.put(5, numberOf5s); // Find largest int maxValueInMap=(Collections.max(birdIndex.values())); // This will return max value in the Hashmap for (Map.Entry entry : birdIndex.entrySet()) { // Itrate through hashmap if (entry.getValue()==maxValueInMap) { System.out.println(entry.getKey()); // Print the key with max value break; } } } }