#!/bin/ruby n = gets.strip.to_i types = gets.strip types = types.split(' ').map(&:to_i) # your code goes here birds = Array.new(5, 0) freq_type = 1 types.each do |type| birds[type - 1] += 1 freq_type = type if birds[type - 1] > birds[freq_type - 1] freq_type = [type, freq_type].min if birds[type - 1] == birds[freq_type - 1] end p freq_type