import std.stdio, std.algorithm, std.string, std.conv, std.array, std.range, std.math;
int read() { return readln.chomp.to!int; }
int[] reads() { return readln.split.to!(int[]); }

void main() {
    int n = read();
    int[] a = reads();

    long f(int b) {
        return iota(n)
            .map!(i => abs(a[i] - (b + i+1)))
            .sum;
    }

    enum N = 2 * 10^^5;
    int lb = -N, rb = N;
    while (rb - lb > 2) {
        int m1 = (lb+lb+rb) / 3;
        int m2 = (lb+rb+rb) / 3;
        if (f(m1) >= f(m2))
            lb = m1;
        else
            rb = m2;
    }
    assert(rb - lb == 2);
    debug {
        writeln(lb, " ", rb);
    }
    int mid = lb + (rb - lb) / 2;
    writeln(f(mid));
}