import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;

long calc(int[] a) {
    int[] a2;
    for (int i = 0; i < a.length; i++)
        a2 ~= a[i] - i - 1;

    long median = a2[a2.length / 2];
    return a2.map!(e => abs(e - median)).sum;
}

void main() {
    readint;
    auto a = readints;
    writeln(calc(a));
}
