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(long[] xs) {
    long dsum = 0;
    for (int i = 0; i < xs.length; i++) {
        long d = xs[i] - (i + 1);
        dsum += d;
    }

    if (dsum >= 0) {
        long x = dsum / xs.length;
        long ans = long.max;
        foreach (b; (x-10)..(x+10)) {
            long sum = 0;
            for (int i = 0; i < xs.length; i++) {
                sum += abs(xs[i] - (b + i + 1));
            }
            ans = min(ans, sum);
        }
        return ans;
    }
    else {
        long x = -dsum / xs.length;
        long ans = long.max;
        foreach (b; x-10..x+10) {
            long sum = 0;
            for (int i = 0; i < xs.length; i++) {
                sum += abs(xs[i] - (-b + i + 1));
            }
            ans = min(ans, sum);
        }
        return ans;
    }
}

void main() {
    readint;
    auto xs = reads!long;
    auto ans = calc(xs);
    writeln(ans);
}