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) { try { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br.readLine(); String[] birdTypes = br.readLine().split(" "); List auxList = Arrays.asList(birdTypes); List typesList = new Vector(auxList); Set typesSet = new HashSet(auxList); int mostCommomType = Integer.parseInt(birdTypes[0]); int occurencesOfMostCommomType = 1; Iterator it = typesSet.iterator(); while(it.hasNext()) { String currentType = it.next(); int occurences = 0; for (int i = 0; i < typesList.size(); i++) { if(currentType.equals(typesList.get(i))) occurences++; } if(occurences >= occurencesOfMostCommomType) { int aux = Integer.parseInt(currentType); if(occurences == occurencesOfMostCommomType) { mostCommomType = Math.min(aux, mostCommomType); } else { mostCommomType = aux; occurencesOfMostCommomType = occurences; } } typesList.removeIf(currentType::equals); } System.out.println(mostCommomType); } catch(Exception e) { e.printStackTrace(); } } }