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

void main() {
    const N = readln.chomp.to!long;
    auto as = readln.split.to!(long[]);
    foreach (i; 0..N) {
        as[i] -= i+1;
    }
    const cs = as.sort!((a,b) => a < b).array;
    if (cs.length % 2 == 0) {
        [cs[$/2], cs[$/2+1]].map!(c => as.map!(a => abs(a - c)).sum).reduce!min.writeln;
    } else {
        as.map!(a => abs(a - cs[$/2])).sum.writeln;
    }
}

