import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math;

void main()
{
    auto N = readln.chomp.to!int;
    auto AS = readln.split.to!(long[]);

    int pc, mc, zc;
    long[] psums, msums;
    long[] VS;
    VS.length = N;
    foreach (i; 0..N) {
        auto v = AS[i] - (i+1);
        if (v > 0) {
            ++pc;
            psums ~= v;
        } else if (v < 0) {
            ++mc;
            msums ~= v;
        } else {
            ++zc;
        }
        VS[i] = v;
    }
    sort(psums);
    sort(msums);
    reverse(msums);
    long cnt;
    if (pc > mc + zc) {
        cnt = psums[pc - mc - zc];
    } else if (mc > pc + zc) {
        cnt = msums[mc - pc - zc];
    }
    long sum_v;
    foreach (v; VS) {
        sum_v += abs(v - cnt);
    }
    writeln(sum_v);
}