from numpy import median



N = int(eval(input()))

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

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

A = sorted(A)

b = int(median(A))

print((sum([abs(i - b) for i in A])))

from numpy import median



N = int(eval(input()))

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

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

b = int(median(A))

print((sum([abs(i - b) for i in A])))

from numpy import median

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

from numpy import median

N = int(eval(input()))
A = list(map(int, input().split()))
A = [a - i - 1 for i, a in enumerate(A)]
b = int(median(A))
print((sum([abs(i - b) for i in A])))

-A = sorted(A)