N = int(eval(input()))

A = [int(x)-i for x,i in zip(input().split(),list(range(1,N+1)))]

from math import ceil,floor

    

A.sort()





if N%2 == 0:

    b = round((A[floor(N/2)]+A[ceil(N/2)])/2)

else:

    b = A[floor(N/2)]

ans = 0

for a in A:

    ans += abs(a-b)

print(ans)
def main():

    N = int(eval(input()))

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

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

    B.sort()

    b = B[N // 2] if N%2 == 1 else round((B[N // 2 - 1] + B[N // 2]) / 2)

    print((sum([abs(bb -b) for bb in B])))

    return



if __name__ == "__main__":

    main()
N = int(eval(input()))
A = [int(x) - i for x, i in zip(input().split(), list(range(1, N + 1)))]
from math import ceil, floor

A.sort()
if N % 2 == 0:
    b = round((A[floor(N / 2)] + A[ceil(N / 2)]) / 2)
else:
    b = A[floor(N / 2)]
ans = 0
for a in A:
    ans += abs(a - b)
print(ans)

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


if __name__ == "__main__":
    main()

-N = int(eval(input())) -A = [int(x) - i for x, i in zip(input().split(), list(range(1, N + 1)))] -from math import ceil, floor +def main(): +    N = int(eval(input())) +    A = list(map(int, input().split())) +    B = [A[i - 1] - i for i in range(1, N + 1)] +    B.sort() +    b = B[N // 2] if N % 2 == 1 else round((B[N // 2 - 1] + B[N // 2]) / 2) +    print((sum([abs(bb - b) for bb in B]))) +    return -A.sort() -if N % 2 == 0: -    b = round((A[floor(N / 2)] + A[ceil(N / 2)]) / 2) -else: -    b = A[floor(N / 2)] -ans = 0 -for a in A: -    ans += abs(a - b) -print(ans) + +if __name__ == "__main__": +    main()