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 objDictionary = new Dictionary(); foreach(int a in types) { if(objDictionary.ContainsKey(a)) { objDictionary[a] = objDictionary[a] + 1; } else { objDictionary.Add(a, 1); } } var maxKey = objDictionary.Aggregate((l, r) => l.Value > r.Value ? l : r).Key; var maxValue = objDictionary.Aggregate((l, r) => l.Value > r.Value ? l : r).Value; if(maxValue > 1) Console.WriteLine(maxKey); else { int minimumKey = objDictionary.Keys.Min(); Console.WriteLine(minimumKey); } } }