N = int(eval(input()))

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

# 中央値

B = []

for i in range(N):

    B.append(A[i] - (i+1))

b = sorted(B)[N//2]



ans = 0

for i in range(N):

    ans += abs(A[i] - (i + 1) - b)



print(ans)



from statistics import median_low



N = int(eval(input()))

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



D = []

for i in range(N):

    D.append(A[i] - (i+1))



m = median_low(D)

ans = 0

for d in D:

    ans += abs(d - m)



print(ans)

N = int(eval(input()))
A = list(map(int, input().split()))
# 中央値
B = []
for i in range(N):
    B.append(A[i] - (i + 1))
b = sorted(B)[N // 2]
ans = 0
for i in range(N):
    ans += abs(A[i] - (i + 1) - b)
print(ans)

from statistics import median_low

N = int(eval(input()))
A = list(map(int, input().split()))
D = []
for i in range(N):
    D.append(A[i] - (i + 1))
m = median_low(D)
ans = 0
for d in D:
    ans += abs(d - m)
print(ans)

+from statistics import median_low + -# 中央値 -B = [] +D = [] -    B.append(A[i] - (i + 1)) -b = sorted(B)[N // 2] +    D.append(A[i] - (i + 1)) +m = median_low(D) -for i in range(N): -    ans += abs(A[i] - (i + 1) - b) +for d in D: +    ans += abs(d - m)