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[] typeCount = new int[6]; //We only need to count 5 types, but I'm including a sixth to make it intuitively easier. for(int i = 0; i < 6; i++){//This is a counting array, so they all need to start at 0. typeCount[i] = 0; } //Okay then. Now we need to count each type. Pretty simple. for(int i = 0; i < n; i++){ typeCount[types[i]]++; //If the given bird is of that type, increment it. } int max = 0; //We know there are at least 5 birds, so this WILL be overriden unless given erroneous input. int result = 0; //The type with the most birds for(int i = 1; i < 6; i++){//We iterate through the types, starting at 1. if(typeCount[i] > max){//By doing strictly less, we give priority to lower ID numbers max = typeCount[i]; result = i; } } System.out.println(result); } }