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(); } Map map = new HashMap<>(); int counter = 1; for(int i : types) { if(map.get(String.valueOf(i)) != null) { map.put(String.valueOf(i), map.get(String.valueOf(i)) + 1); }else { map.put(String.valueOf(i), 1); } } int max = Integer.MIN_VALUE; int id = max; for (Map.Entry entry : map.entrySet()) { //System.out.println(entry.getKey() + "/" + entry.getValue()); if(entry.getValue().intValue() > max) { max = entry.getValue().intValue(); id = Integer.parseInt(entry.getKey().toString()); } } System.out.println(id); } }