import java.io.IOException; import java.io.InputStream; import java.math.BigInteger; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.Comparator; import java.util.HashMap; import java.util.InputMismatchException; import java.util.List; import java.util.Map; import java.util.Map.Entry; import java.util.Scanner; import java.util.Set; public class Solution { public static void main(String[] args) { Scanner sc=new Scanner(System.in); int N=sc.nextInt(); Map freqs=new HashMap(); for(int n=0;n> entries=freqs.entrySet(); List> entryList=new ArrayList>(entries); Collections.sort(entryList, new Comparator>(){ @Override public int compare(Entry entry1, Entry entry2) { int freqComp=entry2.getValue().compareTo(entry1.getValue()); if(freqComp==0){ freqComp=entry1.getKey().compareTo(entry2.getKey()); } return freqComp; } }); int maxFreqKey=entryList.get(0).getKey(); System.out.println(maxFreqKey); } }