using System; using System.Linq; namespace No79 { class Program { static void Main(string[] args) { var a = Int32.Parse(Console.ReadLine()); var b = Console.ReadLine().Split(' ') .GroupBy(x => x) // 入力の数字をキーにしてグループ化 .OrderByDescending(x => x.Count()) // 要素数の多い順(降順)に並び替え .ThenByDescending(x => x.Key) // 要素数が同数の場合、キーの大きい順(降順)に並び替え .First() // 先頭のグループを取得 .Key; // キーを取得 Console.WriteLine(b); Console.ReadKey(); } } }