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(); HashMap counter = new HashMap(); int[] types = new int[n]; for(int types_i=0; types_i < n; types_i++){ types[types_i] = in.nextInt(); if (counter.containsKey(types[types_i])) { int count = counter.get(types[types_i]); counter.replace(types[types_i], ++count); } else { counter.put(types[types_i], 1); } } // your code goes here int max = 0; int birdType = 0; for (Map.Entry entry : counter.entrySet()) { if (entry.getValue() > max) { max = entry.getValue(); birdType = entry.getKey(); } else if (entry.getValue() == max && entry.getKey() < birdType) { birdType = entry.getKey(); } } System.out.println(birdType); } }