N = int(eval(input()))

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





def f(x):

    v = 0

    for i in range(len(A)):

        v += abs(A[i] - (x + i + 1))

    return v





left = -(10**9 + 2 * 10**5)

right = 10**9 + 2 * 10**5

v = 10**18

while left + 1 < right:

    x = (left + right) // 2

    # print('left right x', left, right, x)

    a = f(x)

    v = min(v, a)

    if a <= f(x + 1):

        right = x

    elif f(x - 1) >= a:

        left = x



# ans = f(left)

# print('left ans v', left, ans, v)

print(v)

N = int(eval(input()))

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

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

# print('B', B)





def f(x):

    v = 0

    for i in range(len(B)):

        v += abs(B[i] - x)

    return v





if len(B) % 2 == 0:

    b1 = B[len(B) // 2 - 1]

    b2 = B[len(B) // 2]

    ans = min(f(b1), f(b2))

else:

    b = B[len(B) // 2]

    ans = f(b)

print(ans)

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


def f(x):
    v = 0
    for i in range(len(A)):
        v += abs(A[i] - (x + i + 1))
    return v


left = -(10**9 + 2 * 10**5)
right = 10**9 + 2 * 10**5
v = 10**18
while left + 1 < right:
    x = (left + right) // 2
    # print('left right x', left, right, x)
    a = f(x)
    v = min(v, a)
    if a <= f(x + 1):
        right = x
    elif f(x - 1) >= a:
        left = x
# ans = f(left)
# print('left ans v', left, ans, v)
print(v)

N = int(eval(input()))
A = list(map(int, input().split()))
B = sorted([A[i] - i - 1 for i in range(len(A))])
# print('B', B)
def f(x):
    v = 0
    for i in range(len(B)):
        v += abs(B[i] - x)
    return v


if len(B) % 2 == 0:
    b1 = B[len(B) // 2 - 1]
    b2 = B[len(B) // 2]
    ans = min(f(b1), f(b2))
else:
    b = B[len(B) // 2]
    ans = f(b)
print(ans)

- - +B = sorted([A[i] - i - 1 for i in range(len(A))]) +# print('B', B) -    for i in range(len(A)): -        v += abs(A[i] - (x + i + 1)) +    for i in range(len(B)): +        v += abs(B[i] - x) -left = -(10**9 + 2 * 10**5) -right = 10**9 + 2 * 10**5 -v = 10**18 -while left + 1 < right: -    x = (left + right) // 2 -    # print('left right x', left, right, x) -    a = f(x) -    v = min(v, a) -    if a <= f(x + 1): -        right = x -    elif f(x - 1) >= a: -        left = x -# ans = f(left) -# print('left ans v', left, ans, v) -print(v) +if len(B) % 2 == 0: +    b1 = B[len(B) // 2 - 1] +    b2 = B[len(B) // 2] +    ans = min(f(b1), f(b2)) +else: +    b = B[len(B) // 2] +    ans = f(b) +print(ans)