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 c = cast(long)as.map!(a => cast(double)a / as.length).sum;
    [c, c+1].map!(c => as.map!(a => abs(a - c)).sum).reduce!min.writeln;
}

