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 h=new HashMap(); for(int types_i=0; types_i < n; types_i++){ types[types_i] = in.nextInt(); if(h.containsKey(types[types_i])) { int c=h.get(types[types_i]); c++; h.put(types[types_i],c); } else { h.put(types[types_i],1); } } int max=0; int maxkey=0; for(int key: h.keySet()) { int c=h.get(key); if(c==max){ if(maxkey>key){maxkey=key;} } else if(c>max){ maxkey=key; max=c; } } System.out.println(maxkey); // your code goes here } }