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(); } HashMap birdOccurence = new HashMap (); for (int i = 0; i < types.length; i++) { if (birdOccurence.containsKey(types[i])) { birdOccurence.put(types[i],birdOccurence.get(types[i])+1); } else { birdOccurence.put(types[i],1); } } int commonBird = 0; int commonKey = 0; for (Integer key : birdOccurence.keySet()) { if (birdOccurence.get(key) > commonBird) { commonBird = birdOccurence.get(key); commonKey = key; } if (birdOccurence.get(key) == commonBird && key < commonKey) { commonBird = birdOccurence.get(key); commonKey = key; } } System.out.println(commonKey); } }