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 birds = new Dictionary(); int maxCount = 0; int maxBird = 0; foreach (int i in types) { int count; int newCount = 1; if (birds.TryGetValue(i, out count)) { newCount = count + 1; } birds[i] = newCount; if (newCount > maxCount) { maxCount = newCount; maxBird = i; } else if (newCount == maxCount) { maxBird = Math.Min(maxBird, i); } if (maxCount > (n/2)) { break; } } Console.WriteLine(maxBird); } }