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]; HashMap map = new HashMap<>(); for(int types_i=0; types_i < n; types_i++){ int type = in.nextInt(); //types[types_i] = in.nextInt(); if(map.get(type) != null) { map.put(type, map.get(type) + 1); } else { map.put(type, 1); } } int count = 0, lowest = 0; if(map.size() > 0) { for(Integer key : map.keySet()) { if(count < map.get(key)) { count = map.get(key); lowest = key; } else if(count == map.get(key) && key < lowest) { lowest = key; } } } System.out.println(lowest); // your code goes here } }