"use strict";

process.stdin.resume();
process.stdin.setEncoding('utf8');

var g_input = '';
process.stdin.on('data', function(chunk) {
    g_input += chunk;
});

process.stdin.on('end', function() {
    Main(g_input.split(/\r?\n/));
});

function Main(input) {

    const n = parseInt(input[0], 10);
    const a = input[1].split(' ').map(function(value) { return parseInt(value, 10); });
    const aMinusI = a
    .map(function(value, index) {
        return value - (index + 1);
    })
    .sort(function (a, b) {
        if (a < b) {
            return -1;
        }
        else if (a > b) {
            return 1;
        }
        else {
            return 0;
        }
    });

    const b = aMinusI[Math.floor(n / 2)];

    const ans = aMinusI
    .map(function(value) {
        return Math.abs(value - b);
    })
    .reduce(function(prev, current) {
        return Math.abs(prev + current);
    });

    console.log(ans);

    return 0;
}
