import java.util.Arrays; import java.util.Scanner; public class Yukicoder79 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int N = sc.nextInt(), max = -1, maxIndex = 0; int[] L = new int[N]; for (int i = 0; i < N; i++) L[i] = sc.nextInt(); Arrays.sort(L); int buf = L[0], count = 1; for (int i = 1; i < N; i++) { if (L[i] == buf) { count++; } else { if (count >= max) { max = count; maxIndex = L[i - 1]; } count = 1; buf = L[i]; } } if (count >= max) maxIndex = L[N-1]; System.out.println(maxIndex); } }