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[] xs) {
    // |A[1] - (b+1)| + |A[2] - (b+2)| + ... + |A[n] - (b+n)| を以下に変形
    // |(A[1]-1) - b| + |(A[2]-2) - b| + ... + |(A[n]-n) - b|
    int[] ys;
    for (int i = 0; i < xs.length; i++) {
        ys ~= xs[i] - (i+1);
    }
    ys.sort();
    long mid = ys[ys.length / 2];
    return ys.map!(e => abs(e - mid)).sum;
}

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