N = int(eval(input()))

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



#N = 1

#A = [10**9]*N



A_n = [A[i-1] - i for i in range(1,N+1)]



A_n.sort()



if N%2 == 0:

    cent_max = A_n[N//2]

    cent_min = A_n[N//2-1]

else:

    cent = A_n[N//2]

    

if N%2 == 0:    

    sadness1 = sum([abs(A_n[i]-cent_min) for i in range(N)])

    sadness2 = sum([abs(A_n[i]-cent_max) for i in range(N)])

    sadness = min(sadness1, sadness2)



else:

    sadness = sum([abs(A_n[i]-cent) for i in range(N)])



print(sadness)
import sys

stdin = sys.stdin



sys.setrecursionlimit(10**5)



def li(): return list(map(int, stdin.readline().split()))

def li_(): return [int(x)-1 for x in stdin.readline().split()]

def lf(): return list(map(float, stdin.readline().split()))

def ls(): return stdin.readline().split()

def ns(): return stdin.readline().rstrip()

def lc(): return list(ns())

def ni(): return int(stdin.readline())

def nf(): return float(stdin.readline())



n = ni()

a = list(li())



amini = [ai-(i+1) for i,ai in enumerate(a)]

amini.sort()

b = amini[n//2]



print((sum([abs(ai-(b+i+1)) for i, ai in enumerate(a)])))
N = int(eval(input()))
A = list(map(int, input().split()))
# N = 1
# A = [10**9]*N
A_n = [A[i - 1] - i for i in range(1, N + 1)]
A_n.sort()
if N % 2 == 0:
    cent_max = A_n[N // 2]
    cent_min = A_n[N // 2 - 1]
else:
    cent = A_n[N // 2]
if N % 2 == 0:
    sadness1 = sum([abs(A_n[i] - cent_min) for i in range(N)])
    sadness2 = sum([abs(A_n[i] - cent_max) for i in range(N)])
    sadness = min(sadness1, sadness2)
else:
    sadness = sum([abs(A_n[i] - cent) for i in range(N)])
print(sadness)

import sys

stdin = sys.stdin
sys.setrecursionlimit(10**5)


def li():
    return list(map(int, stdin.readline().split()))


def li_():
    return [int(x) - 1 for x in stdin.readline().split()]


def lf():
    return list(map(float, stdin.readline().split()))


def ls():
    return stdin.readline().split()


def ns():
    return stdin.readline().rstrip()


def lc():
    return list(ns())


def ni():
    return int(stdin.readline())


def nf():
    return float(stdin.readline())


n = ni()
a = list(li())
amini = [ai - (i + 1) for i, ai in enumerate(a)]
amini.sort()
b = amini[n // 2]
print((sum([abs(ai - (b + i + 1)) for i, ai in enumerate(a)])))

-N = int(eval(input())) -A = list(map(int, input().split())) -# N = 1 -# A = [10**9]*N -A_n = [A[i - 1] - i for i in range(1, N + 1)] -A_n.sort() -if N % 2 == 0: -    cent_max = A_n[N // 2] -    cent_min = A_n[N // 2 - 1] -else: -    cent = A_n[N // 2] -if N % 2 == 0: -    sadness1 = sum([abs(A_n[i] - cent_min) for i in range(N)]) -    sadness2 = sum([abs(A_n[i] - cent_max) for i in range(N)]) -    sadness = min(sadness1, sadness2) -else: -    sadness = sum([abs(A_n[i] - cent) for i in range(N)]) -print(sadness) +import sys + +stdin = sys.stdin +sys.setrecursionlimit(10**5) + + +def li(): +    return list(map(int, stdin.readline().split())) + + +def li_(): +    return [int(x) - 1 for x in stdin.readline().split()] + + +def lf(): +    return list(map(float, stdin.readline().split())) + + +def ls(): +    return stdin.readline().split() + + +def ns(): +    return stdin.readline().rstrip() + + +def lc(): +    return list(ns()) + + +def ni(): +    return int(stdin.readline()) + + +def nf(): +    return float(stdin.readline()) + + +n = ni() +a = list(li()) +amini = [ai - (i + 1) for i, ai in enumerate(a)] +amini.sort() +b = amini[n // 2] +print((sum([abs(ai - (b + i + 1)) for i, ai in enumerate(a)])))