from statistics import median

import math

N = int(eval(input()))

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

B = [A[i]-i for i in range(N)]

b = median(B)

bm = math.floor(b)

K = [x - bm for x in B]

KZ = [abs(x) for x in K]

Z = sum(KZ)

for i in range(20):

    C = [abs(x-i+10) for x in K]

    Z = min([sum(C),Z])

print((int(Z)))
from statistics import median

import math

N = int(eval(input()))

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

B = [A[i]-i for i in range(N)]

b = median(B)

bm = math.floor(b)

bM = math.ceil(b)

Bm = [abs(x - bm) for x in B]

BM = [abs(x - bM) for x in B]

m = sum(Bm)

M = sum(BM)

print((int(min([m,M]))))
from statistics import median
import math

N = int(eval(input()))
(*A,) = list(map(int, input().split()))
B = [A[i] - i for i in range(N)]
b = median(B)
bm = math.floor(b)
K = [x - bm for x in B]
KZ = [abs(x) for x in K]
Z = sum(KZ)
for i in range(20):
    C = [abs(x - i + 10) for x in K]
    Z = min([sum(C), Z])
print((int(Z)))

from statistics import median
import math

N = int(eval(input()))
(*A,) = list(map(int, input().split()))
B = [A[i] - i for i in range(N)]
b = median(B)
bm = math.floor(b)
bM = math.ceil(b)
Bm = [abs(x - bm) for x in B]
BM = [abs(x - bM) for x in B]
m = sum(Bm)
M = sum(BM)
print((int(min([m, M]))))

-K = [x - bm for x in B] -KZ = [abs(x) for x in K] -Z = sum(KZ) -for i in range(20): -    C = [abs(x - i + 10) for x in K] -    Z = min([sum(C), Z]) -print((int(Z))) +bM = math.ceil(b) +Bm = [abs(x - bm) for x in B] +BM = [abs(x - bM) for x in B] +m = sum(Bm) +M = sum(BM) +print((int(min([m, M]))))