import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.HashMap;
import java.util.Map;

public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		PrintWriter pw = new PrintWriter(System.out);
		
		Map<Long,Integer> map = new HashMap<>();
		
		int N = Integer.parseInt(br.readLine());
		int max = 0;
		long answer = Long.MAX_VALUE;

		for (int i = 0; i < N; i++) {
			Long key = Long.parseLong(br.readLine());
			if(map.containsKey(key)) {
				int count = map.get(key);
				map.put(key, count+1);
				if(max < count+1) {
					max = count+1;
					answer= key;
				}else if(max == count+1) {
					answer = Math.min(answer, key);
				}
			}else {
				map.put(key, 1);
				if(max <= 1) {
					answer = Math.min(answer, key);
				}
			}
		}
		pw.println(answer);
		pw.flush();
	}
}