///////////////////////No.406 鴨等間隔の法則 //入力文字読み取り process.stdin.resume(); process.stdin.setEncoding('utf8'); process.stdin.on('data', function (chunk) { //すべて受け取り改行で区切って格納 var inputall = chunk.split("\n"); //かもの総数 var ducks = Number(inputall[0]) //すべて受け取り空白で区切って格納 //かもの座標配列 var duckposition = inputall[1].split(" ").map(Number); //かもの座標配列を小さい順にソート duckposition.sort(function (a, b) { if (a < b) return -1; if (a > b) return 1; return 0; }); var result = "YES"; //同じのがあるか判定 for (var i = 0; i < duckposition.length; i++) { for (var j = i + 1; j < duckposition.length-1; j++) { if (duckposition[i] == duckposition[j]) { result = "NO"; break; } } } var difference = []; //座標が等間隔かを調べる for (var i = 0; i < duckposition.length-1; i++) { difference.push(duckposition[i + 1] - duckposition[i]) } for (var i = 0; i < difference.length - 1; i++) { if (difference[i] == difference[i + 1]) { continue; } else { result = "NO"; break; } } console.log(result); });