import java.io.*; import java.util.*; import java.text.*; import java.math.*; import java.util.regex.*; public class Solution { public static void main(String[] args) { Scanner in = new Scanner(System.in); int n = in.nextInt(); int[] types = new int[n]; for(int types_i=0; types_i < n; types_i++){ types[types_i] = in.nextInt(); } int search, count, max = 0, id = 0, tempID = 0, position = 0; boolean found = false; Arrays.sort(types); do{ search = types[position]; count = 0; for(int a = position; a < types.length; a++ ) { if(search == types[a]) { count++; tempID = types[a]; if(a == types.length - 1) //Reach the end of the array found = true; //Finish the do-while loop } else { position = a; break; } } if(max <= count) { if(max == count) id = Math.min(id, tempID); else id = tempID; max = count; } }while(!found); System.out.println(id); } }