n = int(eval(input()))

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

B = []

for i in range(n): B.append(A[i] - (i+1))

B.sort()

r = B[n//2] # median right

l = B[n//2] if n%2 else B[n//2-1] # median left

# print(n,A)

# print(B)

# print(l,r)

ans_l = 0

ans_r = 0

for bi in B:

    ans_l += abs(bi-l)

    ans_r += abs(bi-r)

print((min([ans_l, ans_r])))

n = int(eval(input()))

B = list(a-i for i,a in zip(list(range(1,n+1)), list(map(int,input().split()))))

B.sort()

l = r = B[n//2] # median left, right

if n%2 == 0: l -= 1 # left fix

ans_l, ans_r = 0, 0

for bi in B:

    ans_l += abs(bi-l)

    ans_r += abs(bi-r)

print((min([ans_l, ans_r])))

n = int(eval(input()))
A = list(map(int, input().split()))
B = []
for i in range(n):
    B.append(A[i] - (i + 1))
B.sort()
r = B[n // 2]  # median right
l = B[n // 2] if n % 2 else B[n // 2 - 1]  # median left
# print(n,A)
# print(B)
# print(l,r)
ans_l = 0
ans_r = 0
for bi in B:
    ans_l += abs(bi - l)
    ans_r += abs(bi - r)
print((min([ans_l, ans_r])))

n = int(eval(input()))
B = list(a - i for i, a in zip(list(range(1, n + 1)), list(map(int, input().split()))))
B.sort()
l = r = B[n // 2]  # median left, right
if n % 2 == 0:
    l -= 1  # left fix
ans_l, ans_r = 0, 0
for bi in B:
    ans_l += abs(bi - l)
    ans_r += abs(bi - r)
print((min([ans_l, ans_r])))

-A = list(map(int, input().split())) -B = [] -for i in range(n): -    B.append(A[i] - (i + 1)) +B = list(a - i for i, a in zip(list(range(1, n + 1)), list(map(int, input().split())))) -r = B[n // 2]  # median right -l = B[n // 2] if n % 2 else B[n // 2 - 1]  # median left -# print(n,A) -# print(B) -# print(l,r) -ans_l = 0 -ans_r = 0 +l = r = B[n // 2]  # median left, right +if n % 2 == 0: +    l -= 1  # left fix +ans_l, ans_r = 0, 0