#!/bin/ruby n = gets.strip.to_i types = gets.strip types = types.split(' ').map(&:to_i) # your code goes here h = Hash.new(0) (1..5).each {|t| h[t] = 0 } types.each do |type| h[type] += 1 end res = h.sort_by {|key, val| val }.reverse #p res max = res[0][0] #puts max res.each do |blok| if blok[1] == res.first[1] max = blok.first end end puts max