import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Scanner; public class No79 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); Map map = new HashMap<>(); for (int i = 0; i < n; i++) { int li = sc.nextInt(); if (map.containsKey(li)) { map.put(li, map.get(li) + 1); } else { map.put(li, 1); } } int maxCnt = 0; for (Map.Entry e : map.entrySet()) { if (e.getValue() > maxCnt) { maxCnt = e.getValue(); } } List resultList = new ArrayList<>(); for (Map.Entry e : map.entrySet()) { if (e.getValue() == maxCnt) { resultList.add(e.getKey()); } } Collections.sort(resultList); System.out.println(resultList.get(resultList.size() - 1)); sc.close(); } }