class A def initialize n = gets.chomp.to_i l = gets.chomp.split(' ').map(&:to_i) p l.group_by{|i| l.count(i)}.sort.reverse.to_h.first.last.sort.last end end A.new