import statistics

N = int(eval(input()))

A = [int(a)-(i+1) for i, a in enumerate(input().split())]

ans = float('inf')

medi = int(statistics.median(A))

for b in range(medi-1, medi+2):

  ans = min(ans, sum([abs(A[i]-b) for i in range(N)]))

print(ans)

def calc_sadness(b):

    ans = 0

    for a in A:

        ans += abs(a - b)

    return ans





N = int(eval(input()))

A = []

for idx, a in enumerate(map(int, input().split())):

    A.append(a - idx - 1)

A.sort()



if N % 2 == 0:

    b = [A[N // 2]]

else:

    b = [A[N // 2 - 1], A[N // 2]]



print((min(list(map(calc_sadness, b)))))

import statistics

N = int(eval(input()))
A = [int(a) - (i + 1) for i, a in enumerate(input().split())]
ans = float("inf")
medi = int(statistics.median(A))
for b in range(medi - 1, medi + 2):
    ans = min(ans, sum([abs(A[i] - b) for i in range(N)]))
print(ans)

def calc_sadness(b):
    ans = 0
    for a in A:
        ans += abs(a - b)
    return ans


N = int(eval(input()))
A = []
for idx, a in enumerate(map(int, input().split())):
    A.append(a - idx - 1)
A.sort()
if N % 2 == 0:
    b = [A[N // 2]]
else:
    b = [A[N // 2 - 1], A[N // 2]]
print((min(list(map(calc_sadness, b)))))

-import statistics +def calc_sadness(b): +    ans = 0 +    for a in A: +        ans += abs(a - b) +    return ans + -A = [int(a) - (i + 1) for i, a in enumerate(input().split())] -ans = float("inf") -medi = int(statistics.median(A)) -for b in range(medi - 1, medi + 2): -    ans = min(ans, sum([abs(A[i] - b) for i in range(N)])) -print(ans) +A = [] +for idx, a in enumerate(map(int, input().split())): +    A.append(a - idx - 1) +A.sort() +if N % 2 == 0: +    b = [A[N // 2]] +else: +    b = [A[N // 2 - 1], A[N // 2]] +print((min(list(map(calc_sadness, b)))))