n=int(eval(input()))

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

for i in range(n):

    a[i]-=(i+1)

median=-1

a.sort()

if n%2==0:

    median=(a[n//2]+a[n//2-1])//2

else:

    median=a[n//2]

def comp(x):

    su=0

    for i in a:

        su+=abs(i-x)

    return su

print((min(comp(median-1),comp(median),comp(median+1))))







n=int(eval(input()))

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

for i in range(n):

    a[i]-=(i+1)

median=-1

a.sort()

if n%2==0:

    median=(a[n//2]+a[n//2-1])//2

else:

    median=a[n//2]

def comp(x):

    su=0

    for i in a:

        su+=abs(i-x)

    return su

print((min(comp(median),comp(median+1))))







n = int(eval(input()))
a = list(map(int, input().split()))
for i in range(n):
    a[i] -= i + 1
median = -1
a.sort()
if n % 2 == 0:
    median = (a[n // 2] + a[n // 2 - 1]) // 2
else:
    median = a[n // 2]


def comp(x):
    su = 0
    for i in a:
        su += abs(i - x)
    return su


print((min(comp(median - 1), comp(median), comp(median + 1))))

n = int(eval(input()))
a = list(map(int, input().split()))
for i in range(n):
    a[i] -= i + 1
median = -1
a.sort()
if n % 2 == 0:
    median = (a[n // 2] + a[n // 2 - 1]) // 2
else:
    median = a[n // 2]


def comp(x):
    su = 0
    for i in a:
        su += abs(i - x)
    return su


print((min(comp(median), comp(median + 1))))

-print((min(comp(median - 1), comp(median), comp(median + 1)))) +print((min(comp(median), comp(median + 1))))