function main(input) {
    var n = input[0]-0;
    var list = input[1].split(" ").map(v=>v-0);
    var idx = ~~(n/2);
    var ansi = idx +1 - list[idx];
    var ans = 100000000000000;
    for(var i=0;i<1000;i++){
        ans = Math.min(ans, (Math.min(calc(list, ansi-i), calc(list, ansi+i))));
    }
    console.log(ans);
}
function calc(list, b){
    var ans = 0;
    list.forEach((v,i)=>{
        ans += Math.abs(list[i]-(b+i+1));
    });
    return ans;
}

main(require('fs').readFileSync('/dev/stdin', 'utf8').trim().split("\n"));


