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<>(); for (int i = 0; i < types.length; i++) { // System.out.println(types[i]); map.merge(types[i], 1, (integer, integer2) -> integer + integer2); } int min = 100; int max = 0; for (Map.Entry integerIntegerEntry : map.entrySet()) { if(integerIntegerEntry.getValue() > max){ // System.out.println(integerIntegerEntry); max = integerIntegerEntry.getValue(); min = integerIntegerEntry.getKey(); } else if(integerIntegerEntry.getValue() == max){ max = integerIntegerEntry.getValue(); min = Math.min(min, integerIntegerEntry.getKey()); } } System.out.println(min); } }