function Main(input) {
    const NA = input.split('\n');
    const N = parseInt(NA[0]);
    const A = NA[1].split(' ').map(n => parseInt(n));
    const B = A.map((n, i) => n-(i+1)).sort((a, b) => a-b);
    const b1 = B[parseInt(N/2)];
    const b2 = b1 + 1;
    const min1 = A.reduce((res, n, i) => res += Math.abs(n - (b1+i+1)), 0);
    const min2 = A.reduce((res, n, i) => res += Math.abs(n - (b2+i+1)), 0)
    
    if (min1 < min2) console.log(min1);
    else console.log(min2);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));