import sys

import math

mod=10**9+7

inf=float("inf")

from math import sqrt

from collections import deque

from collections import Counter

input=lambda: sys.stdin.readline().strip()

sys.setrecursionlimit(11451419)

from functools import lru_cache

#メモ化再帰defの冒頭に毎回 @lru_cache(maxsize=10**10)

#引数にlistはだめ

#######ここまでテンプレ#######

#######ここから天ぷら########

n=int(eval(input()))

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

SA=[0 for i in range(n)]

for i in range(n):

    SA[i]=A[i]-i-1

SA.sort()



if n%2==0:

    geta=(SA[n//2]+SA[n//2-1])//2

else:

    geta=SA[n//2]

ans=0

for i in range(n):

    ans+= abs(A[i]-(geta+i+1))

print(ans)

n=int(eval(input()))

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

if n==1:print((0));exit()

A=[A[i]-i-1 for i in range(n)]

B=sorted(A)



#print(B)



if n%2==1:

    d=B[n//2]

    print((sum([abs(A[i]-d) for i in range(n)])))

    exit()



ans=0

d=(B[n//2-1]+B[n//2])//2

print((sum([abs(A[i]-d) for i in range(n)])))

import sys
import math

mod = 10**9 + 7
inf = float("inf")
from math import sqrt
from collections import deque
from collections import Counter

input = lambda: sys.stdin.readline().strip()
sys.setrecursionlimit(11451419)
from functools import lru_cache

# メモ化再帰defの冒頭に毎回 @lru_cache(maxsize=10**10)
# 引数にlistはだめ
#######ここまでテンプレ#######
#######ここから天ぷら########
n = int(eval(input()))
A = list(map(int, input().split()))
SA = [0 for i in range(n)]
for i in range(n):
    SA[i] = A[i] - i - 1
SA.sort()
if n % 2 == 0:
    geta = (SA[n // 2] + SA[n // 2 - 1]) // 2
else:
    geta = SA[n // 2]
ans = 0
for i in range(n):
    ans += abs(A[i] - (geta + i + 1))
print(ans)

n = int(eval(input()))
A = list(map(int, input().split()))
if n == 1:
    print((0))
    exit()
A = [A[i] - i - 1 for i in range(n)]
B = sorted(A)
# print(B)
if n % 2 == 1:
    d = B[n // 2]
    print((sum([abs(A[i] - d) for i in range(n)])))
    exit()
ans = 0
d = (B[n // 2 - 1] + B[n // 2]) // 2
print((sum([abs(A[i] - d) for i in range(n)])))

-import sys -import math - -mod = 10**9 + 7 -inf = float("inf") -from math import sqrt -from collections import deque -from collections import Counter - -input = lambda: sys.stdin.readline().strip() -sys.setrecursionlimit(11451419) -from functools import lru_cache - -# メモ化再帰defの冒頭に毎回 @lru_cache(maxsize=10**10) -# 引数にlistはだめ -#######ここまでテンプレ####### -#######ここから天ぷら######## -SA = [0 for i in range(n)] -for i in range(n): -    SA[i] = A[i] - i - 1 -SA.sort() -if n % 2 == 0: -    geta = (SA[n // 2] + SA[n // 2 - 1]) // 2 -else: -    geta = SA[n // 2] +if n == 1: +    print((0)) +    exit() +A = [A[i] - i - 1 for i in range(n)] +B = sorted(A) +# print(B) +if n % 2 == 1: +    d = B[n // 2] +    print((sum([abs(A[i] - d) for i in range(n)]))) +    exit() -for i in range(n): -    ans += abs(A[i] - (geta + i + 1)) -print(ans) +d = (B[n // 2 - 1] + B[n // 2]) // 2 +print((sum([abs(A[i] - d) for i in range(n)])))