from collections import Counter

N = int(eval(input()))

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

B = [a-i-1 for i,a in enumerate(A)]

ctr = Counter(B)

st = sorted(list(ctr.items()))



left = l_sum = 0

ans = r_sum = sum([(k - st[0][0])*v for k,v in st[1:]])



for (k1,v1),(k2,v2) in zip(st,st[1:]):

    left += v1

    l_sum += left * (k2-k1)

    right = N-left

    r_sum -= right * (k2-k1)

    ans = min(ans, l_sum + r_sum)

print(ans)
N = int(eval(input()))

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

B = [a-i-1 for i,a in enumerate(A)]

med = list(sorted(B))[N//2]

print((sum([abs(a-med) for a in B])))
from collections import Counter

N = int(eval(input()))
A = list(map(int, input().split()))
B = [a - i - 1 for i, a in enumerate(A)]
ctr = Counter(B)
st = sorted(list(ctr.items()))
left = l_sum = 0
ans = r_sum = sum([(k - st[0][0]) * v for k, v in st[1:]])
for (k1, v1), (k2, v2) in zip(st, st[1:]):
    left += v1
    l_sum += left * (k2 - k1)
    right = N - left
    r_sum -= right * (k2 - k1)
    ans = min(ans, l_sum + r_sum)
print(ans)

N = int(eval(input()))
A = list(map(int, input().split()))
B = [a - i - 1 for i, a in enumerate(A)]
med = list(sorted(B))[N // 2]
print((sum([abs(a - med) for a in B])))

-from collections import Counter - -ctr = Counter(B) -st = sorted(list(ctr.items())) -left = l_sum = 0 -ans = r_sum = sum([(k - st[0][0]) * v for k, v in st[1:]]) -for (k1, v1), (k2, v2) in zip(st, st[1:]): -    left += v1 -    l_sum += left * (k2 - k1) -    right = N - left -    r_sum -= right * (k2 - k1) -    ans = min(ans, l_sum + r_sum) -print(ans) +med = list(sorted(B))[N // 2] +print((sum([abs(a - med) for a in B])))