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]; int max =-1; int ty= 0; HashMap map =new HashMap(); for(int types_i=0; types_i < n; types_i++){ int t = in.nextInt(); map.put(t, map.get(t) == null ? 1 :map.get(t) + 1); } for(Map.Entry e: map.entrySet()){ if(max <= e.getValue()){ if(max == e.getValue()){ ty = e.getKey() < ty ? e.getKey() : ty; max = e.getValue(); } else{ ty = e.getKey(); max = e.getValue(); } } } System.out.print(ty); } }