def main():

	N = int(eval(input()))

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

	for i in range(N):

		A[i] -= i+1

	A.sort()





	mid1 = A[N//2]

	mid2 = A[N//2]

	if N >= 2:

		mid2 = A[N//2 + 1]



	ans1 = 0

	ans2 = 0

	for i in range(N):

		ans1 += abs(A[i] - mid1)

		ans2 += abs(A[i] - mid2)



	print((min(ans1, ans2)))





if __name__ == '__main__':

    main()
def main():

	N = int(eval(input()))

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

	for i in range(N):

		A[i] -= i+1

	A.sort()



	mid = A[N//2]

	ans = 0

	for i in range(N):

		ans += abs(A[i] - mid)



	print(ans)





if __name__ == '__main__':

    main()
def main():
    N = int(eval(input()))
    A = list(map(int, input().split()))
    for i in range(N):
        A[i] -= i + 1
    A.sort()
    mid1 = A[N // 2]
    mid2 = A[N // 2]
    if N >= 2:
        mid2 = A[N // 2 + 1]
    ans1 = 0
    ans2 = 0
    for i in range(N):
        ans1 += abs(A[i] - mid1)
        ans2 += abs(A[i] - mid2)
    print((min(ans1, ans2)))


if __name__ == "__main__":
    main()

def main():
    N = int(eval(input()))
    A = list(map(int, input().split()))
    for i in range(N):
        A[i] -= i + 1
    A.sort()
    mid = A[N // 2]
    ans = 0
    for i in range(N):
        ans += abs(A[i] - mid)
    print(ans)


if __name__ == "__main__":
    main()

-    mid1 = A[N // 2] -    mid2 = A[N // 2] -    if N >= 2: -        mid2 = A[N // 2 + 1] -    ans1 = 0 -    ans2 = 0 +    mid = A[N // 2] +    ans = 0 -        ans1 += abs(A[i] - mid1) -        ans2 += abs(A[i] - mid2) -    print((min(ans1, ans2))) +        ans += abs(A[i] - mid) +    print(ans)