from collections import Counter

n=int(eval(input()))

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

for i in range(n):

    a[i]=a[i]-(i+1)

ac=Counter(a)

if len(a)%2==0:

    dist=len(a)//2

else:

    dist=len(a)//2+1

temp=0

for i,j in sorted(ac.items()):

    temp+=j

    if temp>=dist:

        ans=0

        for k in range(n):

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

        print(ans)

        

        exit()
n=int(eval(input()))

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

for i in range(n):

    a[i]=a[i]-(i+1)

import numpy as np

an=np.array(a)

b=int(np.median(an))

ans=0

for i in a:

    ans+=abs(i-b)

print(ans)
from collections import Counter

n = int(eval(input()))
a = list(map(int, input().split()))
for i in range(n):
    a[i] = a[i] - (i + 1)
ac = Counter(a)
if len(a) % 2 == 0:
    dist = len(a) // 2
else:
    dist = len(a) // 2 + 1
temp = 0
for i, j in sorted(ac.items()):
    temp += j
    if temp >= dist:
        ans = 0
        for k in range(n):
            ans += abs(a[k] - i)
        print(ans)
        exit()

n = int(eval(input()))
a = list(map(int, input().split()))
for i in range(n):
    a[i] = a[i] - (i + 1)
import numpy as np

an = np.array(a)
b = int(np.median(an))
ans = 0
for i in a:
    ans += abs(i - b)
print(ans)

-from collections import Counter - -ac = Counter(a) -if len(a) % 2 == 0: -    dist = len(a) // 2 -else: -    dist = len(a) // 2 + 1 -temp = 0 -for i, j in sorted(ac.items()): -    temp += j -    if temp >= dist: -        ans = 0 -        for k in range(n): -            ans += abs(a[k] - i) -        print(ans) -        exit() +import numpy as np + +an = np.array(a) +b = int(np.median(an)) +ans = 0 +for i in a: +    ans += abs(i - b) +print(ans)