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(long b) {
        return iota(n)
            .map!(i => abs(a[i] - (b + i+1)))
            .sum;
    }

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