import java.io.*; import java.util.*; import java.text.*; import java.math.*; import java.util.regex.*; import java.util.Vector; 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 count = 0; int index = 0; HashMap repetitions = new HashMap(); for(int types_i=0; types_i < n; types_i++){ types[types_i] = in.nextInt(); } for ( int i = 0; i < n; i++){ int item = types[i]; if (repetitions.containsKey(item)) repetitions.put(item, repetitions.get(item) + 1); else repetitions.put(item, 1); } for (Map.Entry e : repetitions.entrySet()) { if (e.getValue() > count){ count = e.getValue(); index = e.getKey(); }else if ( e.getValue() == count){ if ( e.getKey() < index){ index = e.getKey(); count = e.getValue(); } } } System.out.println(index); // your code goes here } }