#!/bin/ruby n = gets.strip types = gets.strip types = types.split(' ').map(&:to_i) # your code goes here count_hash = {} (1..5).each do |i| count_hash["#{i}"] = 0 end max_val = 0 max_type = 6 types.each do |t| count_hash["#{t}"] += 1 if count_hash["#{t}"] > max_val max_val = count_hash["#{t}"] max_type = t elsif count_hash["#{t}"] == max_val && t <= max_type max_val = count_hash["#{t}"] max_type = t end end puts max_type