function main(input) {
    var n = input[0]-0;
    var list = input[1].split(" ").map(v=>v-0);
    var idx = ~~(n/2);
    var ans = idx +1 - list[idx];
    console.log(Math.min(calc(list, -ans), calc(list, 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"));


