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