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 dict = new Dictionary(); foreach(var i in types){ if(dict.ContainsKey(i)) dict[i]++; else dict.Add(i, 1); } int result = types[0]; foreach(var i in dict){ if(i.Value > dict[result]) result = i.Key; else if(i.Value == dict[result] && i.Key < result) result = i.Key; } Console.WriteLine(result); } }