'use strict';

const input = require("fs").readFileSync("/dev/stdin", "utf8").split("\n");
const count = parseInt(input[0]);
const inputList = input[1].split(" ");

const process = (input, count) => {
    for (let i=0; i<count; i++) {
        input[i] = parseInt(input[i]) - (i + 1);
    }
    const sorted = input.sort((a,b) => a-b);
    const median = Math.floor(sorted[count/2]);

    return input.reduce((acc, curr) => acc + Math.abs(curr - median), 0);
}

console.log(process(inputList,  count));