# ABC102C - Linear Approximation (ARC100C)

from statistics import median





def main():

    n = int(eval(input()))

    A = tuple(map(int, input().rstrip().split()))

    A = tuple(j - i for i, j in enumerate(A, start=1))

    b = median(A)

    ans = sum(abs(a - b) for a in A)

    print((int(ans)))





if __name__ == "__main__":

    main()
# ABC102C - Linear Approximation (ARC100C)

def main():

    n = int(eval(input()))

    A = tuple(map(int, input().rstrip().split()))

    A = sorted(j - i for i, j in enumerate(A, start=1))

    b = A[n // 2]

    ans = sum(abs(a - b) for a in A)

    print(ans)





if __name__ == "__main__":

    main()
# ABC102C - Linear Approximation (ARC100C)
from statistics import median


def main():
    n = int(eval(input()))
    A = tuple(map(int, input().rstrip().split()))
    A = tuple(j - i for i, j in enumerate(A, start=1))
    b = median(A)
    ans = sum(abs(a - b) for a in A)
    print((int(ans)))


if __name__ == "__main__":
    main()

# ABC102C - Linear Approximation (ARC100C)
def main():
    n = int(eval(input()))
    A = tuple(map(int, input().rstrip().split()))
    A = sorted(j - i for i, j in enumerate(A, start=1))
    b = A[n // 2]
    ans = sum(abs(a - b) for a in A)
    print(ans)


if __name__ == "__main__":
    main()

-from statistics import median - - -    A = tuple(j - i for i, j in enumerate(A, start=1)) -    b = median(A) +    A = sorted(j - i for i, j in enumerate(A, start=1)) +    b = A[n // 2] -    print((int(ans))) +    print(ans)