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 freq = new HashMap<>(); for(int types_i=0; types_i < n; types_i++){ int type = in.nextInt(); types[types_i] = type; if(freq.containsKey(type)){ freq.put(type, freq.get(type)+1); } else{ freq.put(type, 1); } } int maxTypeFreq = -1; int maxType = -1; for(Map.Entry entry : freq.entrySet()){ if(entry.getValue() > maxTypeFreq){ maxTypeFreq = entry.getValue(); maxType = entry.getKey(); } else if(entry.getValue() == maxTypeFreq){ if(entry.getKey() < maxType){ maxType = entry.getKey(); } } } System.out.println(maxType); } }