def calc(xs) if xs.all? {|e| e == xs[0] } if xs[0] == 2 * (xs.size - 1) return [xs.size, 0] else return [0, xs.size] end end crane = xs.count(xs.max) turtle = xs.size - crane [crane, turtle] end gets # read n xs = gets.split.map(&:to_i) ans = calc(xs) puts "#{ans[0]} #{ans[1]}"