n=int(eval(input()))

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



b_low=-1*(10**10)

b_high=10**10

b_low_d=sum([abs(a[i]-(b_low+2+i)) for i in range(n)])-sum([abs(a[i]-(b_low+1+i)) for i in range(n)])

b_high_d=sum([abs(a[i]-(b_high+2+i)) for i in range(n)])-sum([abs(a[i]-(b_high+1+i)) for i in range(n)])



while b_high-b_low>10:

  b_tmp=(b_low+b_high)//2

  b_tmp_d=sum([abs(a[i]-(b_tmp+2+i)) for i in range(n)])-sum([abs(a[i]-(b_tmp+1+i)) for i in range(n)])

  if b_tmp_d>0:

    b_high=b_tmp

  else:

    b_low=b_tmp



ans=10**20

for j in range(b_low,b_high):

  ans=min(ans,sum([abs(a[i]-(j+2+i)) for i in range(n)]))



print(ans)
n=int(eval(input()))

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



arr=sorted([a[i]-i-1 for i in range(n)])



if len(arr)%2==0:

  tmp=[arr[len(arr)//2-1],arr[len(arr)//2]]

else:

  tmp=[arr[len(arr)//2]]



ans=10**20

for b in tmp:

  ans=min(ans,sum([abs(a[i]-b-i-1) for i in range(n)]))

print(ans)
n = int(eval(input()))
a = list(map(int, input().split()))
b_low = -1 * (10**10)
b_high = 10**10
b_low_d = sum([abs(a[i] - (b_low + 2 + i)) for i in range(n)]) - sum(
    [abs(a[i] - (b_low + 1 + i)) for i in range(n)]
)
b_high_d = sum([abs(a[i] - (b_high + 2 + i)) for i in range(n)]) - sum(
    [abs(a[i] - (b_high + 1 + i)) for i in range(n)]
)
while b_high - b_low > 10:
    b_tmp = (b_low + b_high) // 2
    b_tmp_d = sum([abs(a[i] - (b_tmp + 2 + i)) for i in range(n)]) - sum(
        [abs(a[i] - (b_tmp + 1 + i)) for i in range(n)]
    )
    if b_tmp_d > 0:
        b_high = b_tmp
    else:
        b_low = b_tmp
ans = 10**20
for j in range(b_low, b_high):
    ans = min(ans, sum([abs(a[i] - (j + 2 + i)) for i in range(n)]))
print(ans)

n = int(eval(input()))
a = list(map(int, input().split()))
arr = sorted([a[i] - i - 1 for i in range(n)])
if len(arr) % 2 == 0:
    tmp = [arr[len(arr) // 2 - 1], arr[len(arr) // 2]]
else:
    tmp = [arr[len(arr) // 2]]
ans = 10**20
for b in tmp:
    ans = min(ans, sum([abs(a[i] - b - i - 1) for i in range(n)]))
print(ans)

-b_low = -1 * (10**10) -b_high = 10**10 -b_low_d = sum([abs(a[i] - (b_low + 2 + i)) for i in range(n)]) - sum( -    [abs(a[i] - (b_low + 1 + i)) for i in range(n)] -) -b_high_d = sum([abs(a[i] - (b_high + 2 + i)) for i in range(n)]) - sum( -    [abs(a[i] - (b_high + 1 + i)) for i in range(n)] -) -while b_high - b_low > 10: -    b_tmp = (b_low + b_high) // 2 -    b_tmp_d = sum([abs(a[i] - (b_tmp + 2 + i)) for i in range(n)]) - sum( -        [abs(a[i] - (b_tmp + 1 + i)) for i in range(n)] -    ) -    if b_tmp_d > 0: -        b_high = b_tmp -    else: -        b_low = b_tmp +arr = sorted([a[i] - i - 1 for i in range(n)]) +if len(arr) % 2 == 0: +    tmp = [arr[len(arr) // 2 - 1], arr[len(arr) // 2]] +else: +    tmp = [arr[len(arr) // 2]] -for j in range(b_low, b_high): -    ans = min(ans, sum([abs(a[i] - (j + 2 + i)) for i in range(n)])) +for b in tmp: +    ans = min(ans, sum([abs(a[i] - b - i - 1) for i in range(n)]))