# n number of birds n = gets.strip.to_i n.to_i # n spaced-seperated integers describing the respective type numbers of each bird in the flock. types = gets.strip types = types.split(' ').map(&:to_i) types_hash = Hash.new(0) types.each do |t| types_hash[t] += 1 end types_hash = types_hash.sort do |a,b| b <=> a end types_hash.reverse! types_hash = types_hash.sort_by do |k,v| - v end p types_hash[0][0]