# coding: utf-8

import math

n = int(eval(input()))

#x, y = map(int,input().split())

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

ans = 0

B=  []

for i in range(n):

    B.append(A[i]-(i+1))

B.sort()

if n==1:

    m=B[0]

    m2=B[0]

else:

    m = B[n//2]

    m2=B[n//2+1]

tmp1=0

tmp2=0

#print(m,m2)

for i in range(n):

    tmp1 += abs(A[i]-(i+1)-m)

    tmp2 += abs(A[i]-(i+1)-m2)

print((min(tmp1, tmp2)))
# coding: utf-8

n = int(eval(input()))

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

L=[]

for i in range(n):

    L.append(A[i]-(i+1))

L.sort()

#print(L)

if n==1:

    b1=L[0]

    b2=L[0]

elif n==2:

    b1=L[0]

    b2=L[1]

else:

    b1=L[n//2]

    b2=L[n//2-1]

ans=0

cnt1=0

cnt2=0

for i in range(n):

    cnt1+=abs(L[i]-b1)

    cnt2+=abs(L[i]-b2)

print((min(cnt1,cnt2)))
# coding: utf-8
import math

n = int(eval(input()))
# x, y = map(int,input().split())
A = list(map(int, input().split()))
ans = 0
B = []
for i in range(n):
    B.append(A[i] - (i + 1))
B.sort()
if n == 1:
    m = B[0]
    m2 = B[0]
else:
    m = B[n // 2]
    m2 = B[n // 2 + 1]
tmp1 = 0
tmp2 = 0
# print(m,m2)
for i in range(n):
    tmp1 += abs(A[i] - (i + 1) - m)
    tmp2 += abs(A[i] - (i + 1) - m2)
print((min(tmp1, tmp2)))

# coding: utf-8
n = int(eval(input()))
A = list(map(int, input().split()))
L = []
for i in range(n):
    L.append(A[i] - (i + 1))
L.sort()
# print(L)
if n == 1:
    b1 = L[0]
    b2 = L[0]
elif n == 2:
    b1 = L[0]
    b2 = L[1]
else:
    b1 = L[n // 2]
    b2 = L[n // 2 - 1]
ans = 0
cnt1 = 0
cnt2 = 0
for i in range(n):
    cnt1 += abs(L[i] - b1)
    cnt2 += abs(L[i] - b2)
print((min(cnt1, cnt2)))

-import math - -# x, y = map(int,input().split()) +L = [] +for i in range(n): +    L.append(A[i] - (i + 1)) +L.sort() +# print(L) +if n == 1: +    b1 = L[0] +    b2 = L[0] +elif n == 2: +    b1 = L[0] +    b2 = L[1] +else: +    b1 = L[n // 2] +    b2 = L[n // 2 - 1] -B = [] +cnt1 = 0 +cnt2 = 0 -    B.append(A[i] - (i + 1)) -B.sort() -if n == 1: -    m = B[0] -    m2 = B[0] -else: -    m = B[n // 2] -    m2 = B[n // 2 + 1] -tmp1 = 0 -tmp2 = 0 -# print(m,m2) -for i in range(n): -    tmp1 += abs(A[i] - (i + 1) - m) -    tmp2 += abs(A[i] - (i + 1) - m2) -print((min(tmp1, tmp2))) +    cnt1 += abs(L[i] - b1) +    cnt2 += abs(L[i] - b2) +print((min(cnt1, cnt2)))