#coding:utf-8
n = int(input())
A = list(map(int,input().split()))
A = [A[i]-i-1 for i in range(n)]
A = sorted(A)
# print (A)
b = A[n//2]
print (sum([abs(a-b) for a in A]))
6c95ec36e99bd002a0d7d5c2e28d561a2a551b04
<mask token>

<mask token>
print(sum([abs(a - b) for a in A]))

n = int(input())
A = list(map(int, input().split()))
A = [(A[i] - i - 1) for i in range(n)]
A = sorted(A)
b = A[n // 2]
print(sum([abs(a - b) for a in A]))

#coding:utf-8
n = int(input())
A = list(map(int,input().split()))
A = [A[i]-i-1 for i in range(n)]
A = sorted(A)
# print (A)
b = A[n//2]
print (sum([abs(a-b) for a in A]))