#!/bin/ruby n = gets.strip.to_i types = gets.strip types = types.split(' ').map(&:to_i) # your code goes here def find_bird_type(array) counts = Hash.new(0) results = [] array.each do |x| counts[x] = counts[x] + 1 end counts.each {|key, value| results.push(key) if value == counts.values.max } puts results.sort.min end find_bird_type(types)