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 scanner = new Scanner(System.in); int n = scanner.nextInt(); int[] birds = new int[n]; for(int i = 0; i < n; i++) { birds[i] = scanner.nextInt(); } Arrays.sort(birds); int index = birds[n-1]; int count = 1; int maxCount = 0; HashMap map = new HashMap<>(); for(int i = n-2; i >- 1; i--){ if(birds[i] == index){ count++; index = birds[i]; }else{ if(maxCount <= count){ map.clear(); map.put(index, count); maxCount = count; } count = 1; index = birds[i]; } } Integer[] keys = new Integer[map.size()]; map.keySet().toArray(keys); if(map.size() == 1){ System.out.println(keys[0]); }else{ Arrays.sort(keys); System.out.println(keys[0]); } } }