n=int(eval(input()))

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

b=[0]

c=[0]

d=[0]

e=[0]

count=0

count2=0

count3=0

count4=0

for i in range(n):

  a[i]-=i

a.sort()

for i in range(n-1):

  count+=a[i+1]-a[i]

  count3+=a[n-i-1]-a[n-i-2]

  b.append(count)

  d.append(count3)

for i in range(n-1):

  count2+=b[i+1]

  count4+=d[i+1]

  c.append(count2)

  e.append(count4)

ans=10**18

for i in range(n):

  ans=min(ans,c[-1]-c[i]-b[i]*(n-i-1)+e[-1]-e[n-i-1]-d[n-i-1]*i)

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

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

for i in range(n):

  a[i]-=i

a.sort()

x=a[n//2]

ans=0

for i in range(n):

  ans+=abs(a[i]-x)

print(ans)
n = int(eval(input()))
a = list(map(int, input().split()))
b = [0]
c = [0]
d = [0]
e = [0]
count = 0
count2 = 0
count3 = 0
count4 = 0
for i in range(n):
    a[i] -= i
a.sort()
for i in range(n - 1):
    count += a[i + 1] - a[i]
    count3 += a[n - i - 1] - a[n - i - 2]
    b.append(count)
    d.append(count3)
for i in range(n - 1):
    count2 += b[i + 1]
    count4 += d[i + 1]
    c.append(count2)
    e.append(count4)
ans = 10**18
for i in range(n):
    ans = min(
        ans, c[-1] - c[i] - b[i] * (n - i - 1) + e[-1] - e[n - i - 1] - d[n - i - 1] * i
    )
print(ans)

n = int(eval(input()))
a = list(map(int, input().split()))
for i in range(n):
    a[i] -= i
a.sort()
x = a[n // 2]
ans = 0
for i in range(n):
    ans += abs(a[i] - x)
print(ans)

-b = [0] -c = [0] -d = [0] -e = [0] -count = 0 -count2 = 0 -count3 = 0 -count4 = 0 -for i in range(n - 1): -    count += a[i + 1] - a[i] -    count3 += a[n - i - 1] - a[n - i - 2] -    b.append(count) -    d.append(count3) -for i in range(n - 1): -    count2 += b[i + 1] -    count4 += d[i + 1] -    c.append(count2) -    e.append(count4) -ans = 10**18 +x = a[n // 2] +ans = 0 -    ans = min( -        ans, c[-1] - c[i] - b[i] * (n - i - 1) + e[-1] - e[n - i - 1] - d[n - i - 1] * i -    ) +    ans += abs(a[i] - x)