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 birdTypes = new Dictionary(); for (int i = 0; i < n; i++) { if (birdTypes.Keys.Contains(types[i])) { birdTypes[types[i]]++; } else { birdTypes.Add(types[i],1); } } KeyValuePair result = new KeyValuePair(n, 0); foreach (KeyValuePair item in birdTypes) { if (item.Value > result.Value) { result = item; } else if (item.Value == result.Value && item.Key < result.Key) { result = item; } } Console.WriteLine(result.Key); } }