"use strict";
    
const main = arg => {
    arg = arg.trim().split("\n");
    const N = parseInt(arg[0]);
    const a = arg[1].split(" ").map(n=>parseInt(n));
    
    let list = [];
    
    for(let i in a) {
        let temp = a[i] - (parseInt(i) + 1);
        
        list.push(temp);
    }
    
    let b = list.sort((a,b)=>a-b)[Math.floor(N / 2)];
    
    let answer = 0;
    
    for(let i in a) {
        let temp = Math.abs(a[i] - (parseInt(i) + b));
        
        answer += temp;
    }
    
    console.log(answer);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));