# -*- coding: utf-8 -*-



n = int(eval(input()))

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

A = [A[i]-(i+1) for i in range(n)]

A.sort()



if n == 1:

    print((0))

    exit()



ans = 10**100

for i in [n//2-1, n//2]:

    ans = min(ans, sum([abs(A[j]-A[i]) for j in range(n)]))



print(ans)

# -*- coding: utf-8 -*-



n = int(eval(input()))

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

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

A.sort()

ans = 0

for a in A:

    ans += abs(a - A[n//2])

print(ans)

# -*- coding: utf-8 -*-
n = int(eval(input()))
A = list(map(int, input().split()))
A = [A[i] - (i + 1) for i in range(n)]
A.sort()
if n == 1:
    print((0))
    exit()
ans = 10**100
for i in [n // 2 - 1, n // 2]:
    ans = min(ans, sum([abs(A[j] - A[i]) for j in range(n)]))
print(ans)

# -*- coding: utf-8 -*-
n = int(eval(input()))
A = list(map(int, input().split()))
A = [A[i - 1] - i for i in range(1, n + 1)]
A.sort()
ans = 0
for a in A:
    ans += abs(a - A[n // 2])
print(ans)

-A = [A[i] - (i + 1) for i in range(n)] +A = [A[i - 1] - i for i in range(1, n + 1)] -if n == 1: -    print((0)) -    exit() -ans = 10**100 -for i in [n // 2 - 1, n // 2]: -    ans = min(ans, sum([abs(A[j] - A[i]) for j in range(n)])) +ans = 0 +for a in A: +    ans += abs(a - A[n // 2])