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 typesMap = new TreeMap<>(); for (int i = 0; i < types.length; i++) { if (typesMap.get(types[i]) == null) { typesMap.put(types[i], 0); } typesMap.put(types[i], typesMap.get(types[i]) + 1); } int typeMostCommon = 0; int amountMax = 0; for (Map.Entry entry : typesMap.entrySet()) { int amount = entry.getValue(); if (amount > amountMax && amount != amountMax) { amountMax = amount; typeMostCommon = entry.getKey(); } } System.out.print(typeMostCommon); } }