N=int(eval(input()))

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

B=[None]*N



for i in range(N):

    B[i]=A[i]-i-1



B.sort()



Left=0

Right=sum(B)-B[0]*N

ANS=Left+Right

#print(B)

#print(Left,Right)



for i in range(1,N):

    Left=Left+(B[i]-B[i-1])*i

    Right=Right-(B[i]-B[i-1])*(N-i)

    #print(Left,Right)



    if ANS>Left+Right:

        ANS=Left+Right



print(ANS)



N=int(eval(input()))

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



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

B.sort()



B1=[abs(B[i]-B[N//2]) for i in range(N)]

B2=[abs(B[i]-B[N//2-1]) for i in range(N)]



print((min(sum(B1),sum(B2))))
N = int(eval(input()))
A = list(map(int, input().split()))
B = [None] * N
for i in range(N):
    B[i] = A[i] - i - 1
B.sort()
Left = 0
Right = sum(B) - B[0] * N
ANS = Left + Right
# print(B)
# print(Left,Right)
for i in range(1, N):
    Left = Left + (B[i] - B[i - 1]) * i
    Right = Right - (B[i] - B[i - 1]) * (N - i)
    # print(Left,Right)
    if ANS > Left + Right:
        ANS = Left + Right
print(ANS)

N = int(eval(input()))
A = list(map(int, input().split()))
B = [A[i] - (i + 1) for i in range(N)]
B.sort()
B1 = [abs(B[i] - B[N // 2]) for i in range(N)]
B2 = [abs(B[i] - B[N // 2 - 1]) for i in range(N)]
print((min(sum(B1), sum(B2))))

-B = [None] * N -for i in range(N): -    B[i] = A[i] - i - 1 +B = [A[i] - (i + 1) for i in range(N)] -Left = 0 -Right = sum(B) - B[0] * N -ANS = Left + Right -# print(B) -# print(Left,Right) -for i in range(1, N): -    Left = Left + (B[i] - B[i - 1]) * i -    Right = Right - (B[i] - B[i - 1]) * (N - i) -    # print(Left,Right) -    if ANS > Left + Right: -        ANS = Left + Right -print(ANS) +B1 = [abs(B[i] - B[N // 2]) for i in range(N)] +B2 = [abs(B[i] - B[N // 2 - 1]) for i in range(N)] +print((min(sum(B1), sum(B2))))