#!/usr/bin/env python3

n = int(eval(input()))

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

for i in range(n):

    a[i] -= i

a.sort()

b = a[n // 2]

answer = 0

for a_i in a:

    answer += abs(a_i - b)

print(answer)
# ABC102C - Linear Approximation (ARC100C)

def main():

    N, *A = list(map(int, open(0).read().split()))

    B = [j - i for i, j in enumerate(A, 1)]

    B.sort()

    b = B[N // 2]

    ans = sum(abs(i - b) for i in B)

    print(ans)





if __name__ == "__main__":

    main()
#!/usr/bin/env python3
n = int(eval(input()))
a = list(map(int, input().split()))
for i in range(n):
    a[i] -= i
a.sort()
b = a[n // 2]
answer = 0
for a_i in a:
    answer += abs(a_i - b)
print(answer)

# ABC102C - Linear Approximation (ARC100C)
def main():
    N, *A = list(map(int, open(0).read().split()))
    B = [j - i for i, j in enumerate(A, 1)]
    B.sort()
    b = B[N // 2]
    ans = sum(abs(i - b) for i in B)
    print(ans)


if __name__ == "__main__":
    main()

-#!/usr/bin/env python3 -n = int(eval(input())) -a = list(map(int, input().split())) -for i in range(n): -    a[i] -= i -a.sort() -b = a[n // 2] -answer = 0 -for a_i in a: -    answer += abs(a_i - b) -print(answer) +# ABC102C - Linear Approximation (ARC100C) +def main(): +    N, *A = list(map(int, open(0).read().split())) +    B = [j - i for i, j in enumerate(A, 1)] +    B.sort() +    b = B[N // 2] +    ans = sum(abs(i - b) for i in B) +    print(ans) + + +if __name__ == "__main__": +    main()