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 typeFreq = new HashMap(); int highestCount = 0; int mostCommon = 0; for(int i=0; i < n; i++){ int type = in.nextInt(); if (! typeFreq.containsKey(type)) { typeFreq.put(type, 1); } else { typeFreq.put(type, 1 + typeFreq.get(type)); } Integer currentCount = typeFreq.get(type); if (currentCount > highestCount) { highestCount = currentCount; mostCommon = type; } else if (currentCount == highestCount && type < mostCommon) { mostCommon = type; } } System.out.println(mostCommon); } }