n=int(eval(input()))

b=[int(a-(i+1))  for i,a in enumerate(list(map(int,input().split())))]

if n==1:

  print((0))

  exit(0)

bm=b[:]

bm.sort()

mid_1=bm[n//2]

mid_2=bm[(n//2)+1]

ans_1,ans_2=0,0

if n%2==1:

  for bb in b:

    ans_1+=abs(bb-mid_1)

  print(ans_1)

else:

  for bb in b:

    ans_1+=abs(bb-mid_1)

    ans_2+=abs(bb-mid_2)

  print((min(ans_1,ans_2)))



n=int(eval(input()))

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

for i in range(n):

  a[i]-=i+1

b=a[:]

b.sort()

mid1=0

mid2=0

if n%2==1:

  ans=0

  mid1=b[n//2]

  for bb in b:

    ans+=abs(bb-mid1)

  print(ans)

else:

  mid1=b[n//2]

  mid2=b[n//2-1]

  ans1,ans2=0,0

  for bb in b:

    ans1+=abs(bb-mid1)

    ans2+=abs(bb-mid2)

  print((min(ans1,ans2)))

n = int(eval(input()))
b = [int(a - (i + 1)) for i, a in enumerate(list(map(int, input().split())))]
if n == 1:
    print((0))
    exit(0)
bm = b[:]
bm.sort()
mid_1 = bm[n // 2]
mid_2 = bm[(n // 2) + 1]
ans_1, ans_2 = 0, 0
if n % 2 == 1:
    for bb in b:
        ans_1 += abs(bb - mid_1)
    print(ans_1)
else:
    for bb in b:
        ans_1 += abs(bb - mid_1)
        ans_2 += abs(bb - mid_2)
    print((min(ans_1, ans_2)))

n = int(eval(input()))
a = list(map(int, input().split()))
for i in range(n):
    a[i] -= i + 1
b = a[:]
b.sort()
mid1 = 0
mid2 = 0
if n % 2 == 1:
    ans = 0
    mid1 = b[n // 2]
    for bb in b:
        ans += abs(bb - mid1)
    print(ans)
else:
    mid1 = b[n // 2]
    mid2 = b[n // 2 - 1]
    ans1, ans2 = 0, 0
    for bb in b:
        ans1 += abs(bb - mid1)
        ans2 += abs(bb - mid2)
    print((min(ans1, ans2)))

-b = [int(a - (i + 1)) for i, a in enumerate(list(map(int, input().split())))] -if n == 1: -    print((0)) -    exit(0) -bm = b[:] -bm.sort() -mid_1 = bm[n // 2] -mid_2 = bm[(n // 2) + 1] -ans_1, ans_2 = 0, 0 +a = list(map(int, input().split())) +for i in range(n): +    a[i] -= i + 1 +b = a[:] +b.sort() +mid1 = 0 +mid2 = 0 +    ans = 0 +    mid1 = b[n // 2] -        ans_1 += abs(bb - mid_1) -    print(ans_1) +        ans += abs(bb - mid1) +    print(ans) +    mid1 = b[n // 2] +    mid2 = b[n // 2 - 1] +    ans1, ans2 = 0, 0 -        ans_1 += abs(bb - mid_1) -        ans_2 += abs(bb - mid_2) -    print((min(ans_1, ans_2))) +        ans1 += abs(bb - mid1) +        ans2 += abs(bb - mid2) +    print((min(ans1, ans2)))