def c_linear_approximation(N, A):

    import numpy

    B = numpy.array([a-k for k, a in enumerate(A)])

    b = int(numpy.median(B))

    ans = 0

    for b_k in B:

        ans += abs(b_k - b)

    return ans



N = int(eval(input()))

A = [int(i) for i in input().split()]

print((c_linear_approximation(N, A)))
def c_linear_approximation(N, A):

    import numpy

    B = numpy.array([a-k for k, a in enumerate(A)])  # B_k = A_k - k

    b = int(numpy.median(B))  # Bの中央値を選ぶのが最適

    ans = numpy.sum(abs(B - b))  # 実際に悲しみを計算

    return ans



N = int(eval(input()))

A = [int(i) for i in input().split()]

print((c_linear_approximation(N, A)))
def c_linear_approximation(N, A):
    import numpy

    B = numpy.array([a - k for k, a in enumerate(A)])
    b = int(numpy.median(B))
    ans = 0
    for b_k in B:
        ans += abs(b_k - b)
    return ans


N = int(eval(input()))
A = [int(i) for i in input().split()]
print((c_linear_approximation(N, A)))

def c_linear_approximation(N, A):
    import numpy

    B = numpy.array([a - k for k, a in enumerate(A)])  # B_k = A_k - k
    b = int(numpy.median(B))  # Bの中央値を選ぶのが最適
    ans = numpy.sum(abs(B - b))  # 実際に悲しみを計算
    return ans


N = int(eval(input()))
A = [int(i) for i in input().split()]
print((c_linear_approximation(N, A)))

-    B = numpy.array([a - k for k, a in enumerate(A)]) -    b = int(numpy.median(B)) -    ans = 0 -    for b_k in B: -        ans += abs(b_k - b) +    B = numpy.array([a - k for k, a in enumerate(A)])  # B_k = A_k - k +    b = int(numpy.median(B))  # Bの中央値を選ぶのが最適 +    ans = numpy.sum(abs(B - b))  # 実際に悲しみを計算