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[] a = Array.ConvertAll(types_temp,Int32.Parse); // your code goes here var birds = new Dictionary(); for (int i = 0; i < a.Length; i++) { int bird = a[i]; if (birds.ContainsKey(bird)) { ++birds[bird]; } else { birds.Add(bird, 1); } } int birdType = 0; int maxBirds = 0; foreach (var bird in birds) { if (bird.Value >= maxBirds) { if (bird.Value == maxBirds && bird.Key < birdType) { birdType = bird.Key; maxBirds = bird.Value; } else { birdType = bird.Key; maxBirds = bird.Value; } } } Console.WriteLine(birdType.ToString()); } }