using System; namespace yukicoder { class Program { static void Main(string[] args) { int N = int.Parse(Console.ReadLine()); int count = 0 , maxcount = 0 , num = 0; var str = Console.ReadLine(); var g = str.Split(" "); string[] strings = new string[g.Length]; for (int i = 0; i < g.Length; i++) { strings[i] = g[i];//入力された文字を配列に } Array.Sort(strings); for (int j = 0; j < strings.Length - 1; j++) { if (strings[j] == strings[j + 1]) { count++; if (maxcount <= count) { maxcount = count; num = int.Parse(strings[j]); } } else { count = 0; } } if (num == 0) { num = int.Parse(strings[strings.Length - 1]); } Console.WriteLine(num); } } }