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); var migratoryBirds = new MigratoryBirds(types); var type = migratoryBirds.MostCommonBird(); Console.WriteLine(type); } } class MigratoryBirds { private int[] _types = new int[5]; private int[] _birds; public MigratoryBirds(int[] birds) { _birds = birds; } public int MostCommonBird() { var maxType = 6; var maxTypeCount = -1; for (var i = 0; i < _birds.Length; i++) { var birdType = _birds[i]; _types[birdType - 1]++; var birdTypeCount = _types[birdType - 1]; if (birdTypeCount > maxTypeCount || (birdTypeCount == maxTypeCount && maxType > birdType - 1)) { maxTypeCount = birdTypeCount; maxType = birdType - 1; } } return maxType + 1; } }