from math import ceil, floor



N = int(eval(input()))

A = [int(t) for t in input().split()]

if len(A) != N: raise



p = [A[i-1] - i for i in range(1, N+1)]

p.sort()



q = []

for b in p[N//2 - 1 : N//2 + 2]:

    q.append(sum(abs(x - b) for x in p))

print((min(q)))

N = int(eval(input()))

A = [int(t) for t in input().split()]

if len(A) != N: raise



p = [A[i-1] - i for i in range(1, N+1)]

p.sort()



b = p[N // 2]

print((sum(abs(x - b) for x in p)))

from math import ceil, floor

N = int(eval(input()))
A = [int(t) for t in input().split()]
if len(A) != N:
    raise
p = [A[i - 1] - i for i in range(1, N + 1)]
p.sort()
q = []
for b in p[N // 2 - 1 : N // 2 + 2]:
    q.append(sum(abs(x - b) for x in p))
print((min(q)))

N = int(eval(input()))
A = [int(t) for t in input().split()]
if len(A) != N:
    raise
p = [A[i - 1] - i for i in range(1, N + 1)]
p.sort()
b = p[N // 2]
print((sum(abs(x - b) for x in p)))

-from math import ceil, floor - -q = [] -for b in p[N // 2 - 1 : N // 2 + 2]: -    q.append(sum(abs(x - b) for x in p)) -print((min(q))) +b = p[N // 2] +print((sum(abs(x - b) for x in p)))