// Enter your code here let n = Int(readLine()!)! let birdString = readLine()! let birds = birdString.characters.filter{ $0 != " " }.map { Int(String($0))! } var typeCounter: [Int: Int] = [ 1: 0, 2: 0, 3: 0, 4: 0, 5: 0 ] for var type in birds { typeCounter[type] = typeCounter[type]! + 1 } var typeSeen = 0 var highestCount = 0 for (type, count) in typeCounter { if count > highestCount { highestCount = count typeSeen = type } else if count == highestCount { if typeSeen > type { typeSeen = type } } } print(typeSeen)