/******************************************************************************
Online Java Compiler.
Code, Compile, Run and Debug java program online.
Write your code in this editor and press "Run" button to execute it.
*******************************************************************************/
import java.io.*;
import java.util.*;
public class Main {
public static void main(String[] args) throws Exception {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int N = Integer.parseInt(br.readLine());
HashMap<Long, Integer> map = new HashMap<>();
for(int i=0; i<N; i++) {
Long number = Long.parseLong(br.readLine());
map.put(number, map.getOrDefault(number, 1)+1);
}
List<Map.Entry<Long, Integer>> list = new ArrayList<Map.Entry<Long,Integer>>();
list.addAll(map.entrySet());
Collections.sort(list, new Comparator<Map.Entry<Long, Integer>>() {
@Override
public int compare(Map.Entry<Long, Integer> o1, Map.Entry<Long, Integer> o2) {
if(o1.getValue()==o2.getValue())
return Long.compare(o1.getKey(), o2.getKey());
return Integer.compare(o2.getValue(), o1.getValue());
}
});
System.out.println(list.get(0).getKey());
}
}