import numpy as np

ans=0

N=int(eval(input()))

s1,s_1,s0=[],[],[]

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

s_=np.array(s)-np.array(list(range(N)))

for i in s_:

    if i<0:

        s_1.append(i)

    elif i==0:

        s0.append(i)

    else:

        s1.append(i)

if len(s1)==len(s_1) or (max(len(s1),len(s_1))<=min(len(s1),len(s_1))+len(s0)):

    print((-1*sum(s_1)+sum(s1)))

    exit()

s1=sorted(s1)

s_1=sorted(s_1)

p=len(s1)-len(s_1)-len(s0)

q=len(s_1)-len(s1)-len(s0)

t=(max(p,q)-1)//2

if p>0:

    t=s1[t]

if q>0:

    t=s_1[t*(-1)-1]

ss=s1+s0+s_1

for i in ss:

    ans+=abs(i-t)

print(ans)

N=int(eval(input()))

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

for i in range(N):

    s[i]-=i

s.sort()

print((sum(list([abs(x-s[N//2]) for x in s]))))
import numpy as np

ans = 0
N = int(eval(input()))
s1, s_1, s0 = [], [], []
s = list(map(int, input().split()))
s_ = np.array(s) - np.array(list(range(N)))
for i in s_:
    if i < 0:
        s_1.append(i)
    elif i == 0:
        s0.append(i)
    else:
        s1.append(i)
if len(s1) == len(s_1) or (max(len(s1), len(s_1)) <= min(len(s1), len(s_1)) + len(s0)):
    print((-1 * sum(s_1) + sum(s1)))
    exit()
s1 = sorted(s1)
s_1 = sorted(s_1)
p = len(s1) - len(s_1) - len(s0)
q = len(s_1) - len(s1) - len(s0)
t = (max(p, q) - 1) // 2
if p > 0:
    t = s1[t]
if q > 0:
    t = s_1[t * (-1) - 1]
ss = s1 + s0 + s_1
for i in ss:
    ans += abs(i - t)
print(ans)

N = int(eval(input()))
s = list(map(int, input().split()))
for i in range(N):
    s[i] -= i
s.sort()
print((sum(list([abs(x - s[N // 2]) for x in s]))))

-import numpy as np - -ans = 0 -s1, s_1, s0 = [], [], [] -s_ = np.array(s) - np.array(list(range(N))) -for i in s_: -    if i < 0: -        s_1.append(i) -    elif i == 0: -        s0.append(i) -    else: -        s1.append(i) -if len(s1) == len(s_1) or (max(len(s1), len(s_1)) <= min(len(s1), len(s_1)) + len(s0)): -    print((-1 * sum(s_1) + sum(s1))) -    exit() -s1 = sorted(s1) -s_1 = sorted(s_1) -p = len(s1) - len(s_1) - len(s0) -q = len(s_1) - len(s1) - len(s0) -t = (max(p, q) - 1) // 2 -if p > 0: -    t = s1[t] -if q > 0: -    t = s_1[t * (-1) - 1] -ss = s1 + s0 + s_1 -for i in ss: -    ans += abs(i - t) -print(ans) +for i in range(N): +    s[i] -= i +s.sort() +print((sum(list([abs(x - s[N // 2]) for x in s]))))