//入力文字読み取り process.stdin.resume(); process.stdin.setEncoding('utf8'); process.stdin.on('data', function (chunk) { //すべて受け取り改行で区切って格納 var inputall = chunk.split("\n"); //座標点の合計値 var coordinateall =Number( inputall[0]); //座標点をひとつずつを配列に格納 var coordinate = inputall[1].split(" ").map(Number); //座標点をソート coordinate.sort( function (a, b) { if (a < b) return -1; if (a > b) return 1; return 0; }); var count = 10000000 for (var i = 0; i < coordinateall-1; i++) { var coordinate_difference = coordinate[i + 1] - coordinate[i] if (coordinate_difference < count && coordinate_difference != 0) { count = coordinate_difference; } } console.log(count) });