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(); } // your code goes here int value,maxCount = 0,minValue = 0; HashMap map = new HashMap(); for(int types_i=0; types_i < n; types_i++) { if(map.containsKey(types[types_i])) { value = map.get(types[types_i]) + 1; } else { value = 1; } map.put(types[types_i],value); } for(Integer key:map.keySet()){ if(maxCount < map.get(key)){ maxCount = map.get(key); minValue = key; } else if(maxCount == map.get(key)) { if(minValue > key){ minValue = key; } } } System.out.println(minValue); } }