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); Dictionary dic = new Dictionary(); int count = 0; foreach (var grp in types.GroupBy(i => i)) { int track = grp.Count(); if (track > count) { count = grp.Count(); } dic.Add(grp.Key, grp.Count()); } var min = dic.Where(a => a.Value == count).Min(a => a.Key); Console.WriteLine(min); } }