N = int(eval(input()))

A = list(map(int, input().split()))

B = [A[i] - 1 - i for i in range(N)]

B.sort()

if N % 2 == 0:

    med = [B[int(N / 2) - 1], int((B[int(N / 2) - 1] + B[int(N / 2)]) / 2), B[int(N / 2)]]

else:

    med = [B[int((N + 1) / 2) - 1]]

ans = 10 ** 100

for b in med:

    S = 0

    for i in range(N):

        S += abs(B[i] - b)

    ans = min(ans, S)

print(ans)

N = int(eval(input()))

A = list(map(int, input().split()))

B = [A[i] - 1 - i for i in range(N)]

B.sort()

if N % 2 == 0:

    med = int((B[int(N / 2) - 1] + B[int(N / 2)]) / 2)

else:

    med = B[int((N + 1) / 2) - 1]

S = 0

for i in range(N):

    S += abs(B[i] - med)

print(S)

N = int(eval(input()))
A = list(map(int, input().split()))
B = [A[i] - 1 - i for i in range(N)]
B.sort()
if N % 2 == 0:
    med = [
        B[int(N / 2) - 1],
        int((B[int(N / 2) - 1] + B[int(N / 2)]) / 2),
        B[int(N / 2)],
    ]
else:
    med = [B[int((N + 1) / 2) - 1]]
ans = 10**100
for b in med:
    S = 0
    for i in range(N):
        S += abs(B[i] - b)
    ans = min(ans, S)
print(ans)

N = int(eval(input()))
A = list(map(int, input().split()))
B = [A[i] - 1 - i for i in range(N)]
B.sort()
if N % 2 == 0:
    med = int((B[int(N / 2) - 1] + B[int(N / 2)]) / 2)
else:
    med = B[int((N + 1) / 2) - 1]
S = 0
for i in range(N):
    S += abs(B[i] - med)
print(S)

-    med = [ -        B[int(N / 2) - 1], -        int((B[int(N / 2) - 1] + B[int(N / 2)]) / 2), -        B[int(N / 2)], -    ] +    med = int((B[int(N / 2) - 1] + B[int(N / 2)]) / 2) -    med = [B[int((N + 1) / 2) - 1]] -ans = 10**100 -for b in med: -    S = 0 -    for i in range(N): -        S += abs(B[i] - b) -    ans = min(ans, S) -print(ans) +    med = B[int((N + 1) / 2) - 1] +S = 0 +for i in range(N): +    S += abs(B[i] - med) +print(S)