NUM_ANIMALS = gets.to_i ANSWERS = gets.split.map(&:to_i) TOTAL_LEGS = ANSWERS.reduce(:+) / (NUM_ANIMALS - 1) NUM_TSURUS = (4 * NUM_ANIMALS - TOTAL_LEGS) / 2 puts "#{NUM_TSURUS} #{NUM_ANIMALS - NUM_TSURUS}"