# coding: utf-8

import sys

import numpy as np



sr = lambda: sys.stdin.readline().rstrip()

ir = lambda: int(sr())

lr = lambda: list(map(int, sr().split()))



N = ir()

A = np.array(lr())

A -= np.arange(1, N+1)

A.sort()



def check(i):

    ret = np.abs(A - A[i]).sum()

    return ret



answer = min(check(0), check(-1))

left = 0; right = N-1

l_mid = (left*2 + right) // 3

r_mid = (left + right*2) // 3

while abs(right-left) > 2:

    l_mid = (left*2 + right) // 3

    r_mid = (left + right*2) // 3

    if check(l_mid) < check(r_mid):

        right = r_mid

    else:

        left = l_mid



cand = min(check(l_mid), check(r_mid))

answer = min(answer, cand)

print(answer)

# coding: utf-8

import sys

import numpy as np



sr = lambda: sys.stdin.readline().rstrip()

ir = lambda: int(sr())

lr = lambda: list(map(int, sr().split()))



N = ir()

A = np.array(lr(), dtype=np.int32)

A -= np.arange(1, N+1)

answer = np.abs(A - int(np.median(A))).sum()

print(answer)

# coding: utf-8
import sys
import numpy as np

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))
N = ir()
A = np.array(lr())
A -= np.arange(1, N + 1)
A.sort()


def check(i):
    ret = np.abs(A - A[i]).sum()
    return ret


answer = min(check(0), check(-1))
left = 0
right = N - 1
l_mid = (left * 2 + right) // 3
r_mid = (left + right * 2) // 3
while abs(right - left) > 2:
    l_mid = (left * 2 + right) // 3
    r_mid = (left + right * 2) // 3
    if check(l_mid) < check(r_mid):
        right = r_mid
    else:
        left = l_mid
cand = min(check(l_mid), check(r_mid))
answer = min(answer, cand)
print(answer)

# coding: utf-8
import sys
import numpy as np

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))
N = ir()
A = np.array(lr(), dtype=np.int32)
A -= np.arange(1, N + 1)
answer = np.abs(A - int(np.median(A))).sum()
print(answer)

-A = np.array(lr()) +A = np.array(lr(), dtype=np.int32) -A.sort() - - -def check(i): -    ret = np.abs(A - A[i]).sum() -    return ret - - -answer = min(check(0), check(-1)) -left = 0 -right = N - 1 -l_mid = (left * 2 + right) // 3 -r_mid = (left + right * 2) // 3 -while abs(right - left) > 2: -    l_mid = (left * 2 + right) // 3 -    r_mid = (left + right * 2) // 3 -    if check(l_mid) < check(r_mid): -        right = r_mid -    else: -        left = l_mid -cand = min(check(l_mid), check(r_mid)) -answer = min(answer, cand) +answer = np.abs(A - int(np.median(A))).sum()