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 Dictionary temp = new Dictionary(); for(int i = 0; i < n; i++) { if(!temp.ContainsKey(types[i])) { temp.Add(types[i], 1); } else { temp[types[i]]++; } } int max = int.MinValue; int correspondingKey = -1; foreach(var pair in temp) { if(pair.Value > max) { max = pair.Value; correspondingKey = pair.Key; } else if(pair.Value == max) { if(pair.Key < correspondingKey) { correspondingKey = pair.Key; } } } Console.WriteLine(correspondingKey); } }