N = int(eval(input()))

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



ans = sum(A)



imin = min(A)-N

imax = max(A)+N



def calcAns(b):

        global A

        return sum([abs(A[i]-(b+i+1)) for i in range(N)])



while True:

        if imin == imax:

                break

        else:

                imid = imin + (imax - imin)//2

                tmp = calcAns(imid)

                if calcAns(imid+1)<tmp:

                        imin = imid+1

                elif calcAns(imid-1)<tmp:

                        imax = imid-1

                else:

                        imin = imid

                        imax = imid



print((calcAns(imin)))
N = int(eval(input()))

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



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

B.sort()

if N%2:

        b = B[(N-1)//2]

else:

        b = (B[N//2]+B[N//2 - 1])//2



print((sum([abs(A[i]-b-i-1) for i in range(N)])))
N = int(eval(input()))
A = list(map(int, input().split()))
ans = sum(A)
imin = min(A) - N
imax = max(A) + N


def calcAns(b):
    global A
    return sum([abs(A[i] - (b + i + 1)) for i in range(N)])


while True:
    if imin == imax:
        break
    else:
        imid = imin + (imax - imin) // 2
        tmp = calcAns(imid)
        if calcAns(imid + 1) < tmp:
            imin = imid + 1
        elif calcAns(imid - 1) < tmp:
            imax = imid - 1
        else:
            imin = imid
            imax = imid
print((calcAns(imin)))

N = int(eval(input()))
A = list(map(int, input().split()))
B = [A[i] - i - 1 for i in range(N)]
B.sort()
if N % 2:
    b = B[(N - 1) // 2]
else:
    b = (B[N // 2] + B[N // 2 - 1]) // 2
print((sum([abs(A[i] - b - i - 1) for i in range(N)])))

-ans = sum(A) -imin = min(A) - N -imax = max(A) + N - - -def calcAns(b): -    global A -    return sum([abs(A[i] - (b + i + 1)) for i in range(N)]) - - -while True: -    if imin == imax: -        break -    else: -        imid = imin + (imax - imin) // 2 -        tmp = calcAns(imid) -        if calcAns(imid + 1) < tmp: -            imin = imid + 1 -        elif calcAns(imid - 1) < tmp: -            imax = imid - 1 -        else: -            imin = imid -            imax = imid -print((calcAns(imin))) +B = [A[i] - i - 1 for i in range(N)] +B.sort() +if N % 2: +    b = B[(N - 1) // 2] +else: +    b = (B[N // 2] + B[N // 2 - 1]) // 2 +print((sum([abs(A[i] - b - i - 1) for i in range(N)])))