SOURCE

// acm 读取多行输入
// let n = readInt();
// let arr = [];
// for(let i = 0; i < n; i++) {
//     arr[i] = read_line();
// }

// 7 1(n-1)
// var arr = [6,0,2,-2,3];
var arr = [7,0,1,1,1]
var count = 0;
arr.sort(function(a,b) {
    return Math.abs(7-Math.abs(a)) - Math.abs(7-Math.abs(b));
})
console.log(arr)
count = Math.abs(7-Math.abs(arr[0]));
console.log(count)
var newArr = arr.slice(1);
console.log("newArr=>",newArr)
for(let i = 0; i < newArr.length; i++) {
    if(newArr[i] > 0) {
        count += newArr[i] - 1;
    }else {
        count += 1 - newArr[i];
    }
    console.log(newArr[i],count)
}
console.log(count);
console 命令行工具 X clear

                    
>
console