import statistics

n,*a=list(map(int,open(0).read().split()))

b=[q-i for i,q in enumerate(a,1)]

c=statistics.median(b)

ans=sum(map(abs,[p-c for p in b]))

print((int(ans)))

from numpy import*

n=int(eval(input()))

a=array(list(map(int,input().split())))

b=a-arange(1,n+1)

c=median(b)

d=abs(b-c).sum()

print((int(d)))
import statistics

n, *a = list(map(int, open(0).read().split()))
b = [q - i for i, q in enumerate(a, 1)]
c = statistics.median(b)
ans = sum(map(abs, [p - c for p in b]))
print((int(ans)))

from numpy import *

n = int(eval(input()))
a = array(list(map(int, input().split())))
b = a - arange(1, n + 1)
c = median(b)
d = abs(b - c).sum()
print((int(d)))

-import statistics +from numpy import * -n, *a = list(map(int, open(0).read().split())) -b = [q - i for i, q in enumerate(a, 1)] -c = statistics.median(b) -ans = sum(map(abs, [p - c for p in b])) -print((int(ans))) +n = int(eval(input())) +a = array(list(map(int, input().split()))) +b = a - arange(1, n + 1) +c = median(b) +d = abs(b - c).sum() +print((int(d)))