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