import statistics

N = int(eval(input()))

a = [int(i) for i in input().split()]

ans = 0



for i in range(1,N+1):

  a[i-1] -= i



b = statistics.median(a)

for i in range(N):

  ans += abs(a[i]-b)

print((int(ans)))
N = int(eval(input()))

A = [int(i) for i in input().split()]

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

C.sort()

ans = 0

med = C[N//2]

for i in range(N):

  ans += abs(C[i]-med)

print(ans)
import statistics

N = int(eval(input()))
a = [int(i) for i in input().split()]
ans = 0
for i in range(1, N + 1):
    a[i - 1] -= i
b = statistics.median(a)
for i in range(N):
    ans += abs(a[i] - b)
print((int(ans)))

N = int(eval(input()))
A = [int(i) for i in input().split()]
C = [A[i] - i for i in range(N)]
C.sort()
ans = 0
med = C[N // 2]
for i in range(N):
    ans += abs(C[i] - med)
print(ans)

-import statistics - -a = [int(i) for i in input().split()] +A = [int(i) for i in input().split()] +C = [A[i] - i for i in range(N)] +C.sort() -for i in range(1, N + 1): -    a[i - 1] -= i -b = statistics.median(a) +med = C[N // 2] -    ans += abs(a[i] - b) -print((int(ans))) +    ans += abs(C[i] - med) +print(ans)