import math

N = int(eval(input()))

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

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

A.sort()

c = int(math.floor(N/2))

answer = sum(list(map(abs,[A[i] - A[c] for i in range(N)])))

print(answer)
def main():

    N = int(eval(input()))

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

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

    b = B[N//2]

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



if __name__ == "__main__":

    main()
import math

N = int(eval(input()))
A = list(map(int, input().split()))
A = [A[i] - i - 1 for i in range(N)]
A.sort()
c = int(math.floor(N / 2))
answer = sum(list(map(abs, [A[i] - A[c] for i in range(N)])))
print(answer)

def main():
    N = int(eval(input()))
    A = list(map(int, input().split()))
    B = sorted([A[i] - (i + 1) for i in range(N)])
    b = B[N // 2]
    print((sum([abs(val - b) for val in B])))


if __name__ == "__main__":
    main()

-import math +def main(): +    N = int(eval(input())) +    A = list(map(int, input().split())) +    B = sorted([A[i] - (i + 1) for i in range(N)]) +    b = B[N // 2] +    print((sum([abs(val - b) for val in B]))) -N = int(eval(input())) -A = list(map(int, input().split())) -A = [A[i] - i - 1 for i in range(N)] -A.sort() -c = int(math.floor(N / 2)) -answer = sum(list(map(abs, [A[i] - A[c] for i in range(N)]))) -print(answer) + +if __name__ == "__main__": +    main()