input = open(0).read



N, *An = list(map(int, input().split()))





def main():

    for i in range(N):

        An[i] = An[i] - i - 1



    ans = 0



    An.sort()



    for i in range(N):

        ans += abs(An[i] - An[N // 2])



    print(ans)

    return





main()

def main():

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

    for i in range(N):

        A[i] -= i + 1

    A.sort()

    ans = 0

    b = A[N // 2]

    for i in range(N):

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

    print(ans)

    return





main()

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


def main():
    for i in range(N):
        An[i] = An[i] - i - 1
    ans = 0
    An.sort()
    for i in range(N):
        ans += abs(An[i] - An[N // 2])
    print(ans)
    return


main()

def main():
    N, *A = list(map(int, open(0).read().split()))
    for i in range(N):
        A[i] -= i + 1
    A.sort()
    ans = 0
    b = A[N // 2]
    for i in range(N):
        ans += abs(A[i] - b)
    print(ans)
    return


main()

-input = open(0).read -N, *An = list(map(int, input().split())) - - +    N, *A = list(map(int, open(0).read().split())) -        An[i] = An[i] - i - 1 +        A[i] -= i + 1 +    A.sort() -    An.sort() +    b = A[N // 2] -        ans += abs(An[i] - An[N // 2]) +        ans += abs(A[i] - b)