/////////////////////////////////No.112 ややこしい鶴亀算 //入力文字読み取り var inputall = require('fs').readFileSync('/dev/stdin', 'utf8'); //すべて受け取り改行で区切って格納 var input = inputall.split("\n"); //動物数 var animals = Number(input[0]); //動物が数えた足の総本数 var animal_legs = input[1].split(" ").map(Number); var max = -1; var min = 10000000000; var sum = 0; for (var i = 0; i < animals; i++) { max = Math.max(max, animal_legs[i]); min = Math.min(min, animal_legs[i]); sum += animal_legs[i]; } var crane_count = 0; var turtle_count = 0; for (var i = 0; i < animals; i++) { if (max == min) { if (sum / animals == 4) { crane_count++; } else { turtle_count++; } } else { if (animal_legs[i] == max) { crane_count++; } else { turtle_count++; } } } console.log(crane_count + " " + turtle_count);