import numpy as np

n = int(eval(input()))

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



for i in range(n):

    al[i] -= i + 1



med = np.median(np.array(al))



ans = 0

for a in al:

    ans += abs(a-med)

print((int(ans)))
import statistics

n = int(eval(input()))

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



for i in range(n):

    al[i] -= i + 1



median = statistics.median(al)



ans = 0

for a in al:

    ans += abs(median - a)



print((int(ans)))

import numpy as np

n = int(eval(input()))
al = list(map(int, input().split()))
for i in range(n):
    al[i] -= i + 1
med = np.median(np.array(al))
ans = 0
for a in al:
    ans += abs(a - med)
print((int(ans)))

import statistics

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

-import numpy as np +import statistics -med = np.median(np.array(al)) +median = statistics.median(al) -    ans += abs(a - med) +    ans += abs(median - a)