NUM_OF_ANIMALS = gets.to_i GROUPED_ANSWERS = gets.split.map(&:to_i).group_by{|e|e} if GROUPED_ANSWERS.keys.size != 1 puts GROUPED_ANSWERS.map { |k, v| v.size }.reverse.join(" ") elsif GROUPED_ANSWERS.keys[0].to_i == ((NUM_OF_ANIMALS - 1) * 2) puts "#{NUM_OF_ANIMALS} 0" else puts "0 #{NUM_OF_ANIMALS}" end