import numpy as np

N = int(eval(input()))

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

list1 = [x-(i+1) for i,x in enumerate(list_ai)]

a1 = np.array(list1)

median1 = int(np.floor(np.median(a1)))

ans = np.sum(np.abs(a1-median1))

print(ans)
import numpy as np

N = int(eval(input()))

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

a1 = np.array(list_ai)-np.arange(1,N+1)

median1 = int(np.floor(np.median(a1)))

ans = np.sum(np.abs(a1-median1))

print(ans)

import numpy as np

N = int(eval(input()))
list_ai = list(map(int, input().split()))
list1 = [x - (i + 1) for i, x in enumerate(list_ai)]
a1 = np.array(list1)
median1 = int(np.floor(np.median(a1)))
ans = np.sum(np.abs(a1 - median1))
print(ans)

import numpy as np

N = int(eval(input()))
list_ai = list(map(int, input().split()))
a1 = np.array(list_ai) - np.arange(1, N + 1)
median1 = int(np.floor(np.median(a1)))
ans = np.sum(np.abs(a1 - median1))
print(ans)

-list1 = [x - (i + 1) for i, x in enumerate(list_ai)] -a1 = np.array(list1) +a1 = np.array(list_ai) - np.arange(1, N + 1)