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 maxQuantity = 1; int smallestBirdType = 5; Map birdTypesAndItsQuantities = new HashMap(); for (int i = 0; i < types.length; i++){ if( birdTypesAndItsQuantities.get(types[i]) == null ) { birdTypesAndItsQuantities.put(types[i], 1); } else { birdTypesAndItsQuantities.put(types[i], birdTypesAndItsQuantities.get(types[i]) + 1); if( maxQuantity < birdTypesAndItsQuantities.get(types[i]) ){ maxQuantity++; if(types[i] < smallestBirdType ){ smallestBirdType = types[i]; } } } } System.out.println(smallestBirdType); } }