using System; using System.Collections.Generic; using System.IO; using System.Linq; class Solution { static void Main(String[] args) { int n = Convert.ToInt32(Console.ReadLine()); string[] types_temp = Console.ReadLine().Split(' '); int[] types = Array.ConvertAll(types_temp, Int32.Parse); // your code goes here int maxCount = 0; int maxType = 0; int[] counter = new int[n]; foreach (int i in types) { counter[i]++; if(counter[i] == maxCount && i < maxType) { maxType = i; } else if (counter[i] > maxCount) { maxType = i; maxCount = counter[i]; } } Console.WriteLine(maxType); } }