import math

import statistics

N = int(eval(input()))

L = [i for i in map(int,input().split())]

Q = []

for i in range(len(L)):

  Q.append(L[i] - (i+1))

b = statistics.median(Q)

a = b - 1

c = b + 1

res = 0

res2 = 0

res3 = 0

for i in range(N):

  res += abs(L[i] - (i+1) - b)

  res2 += abs(L[i] - (i+1) - a)

  res3 += abs(L[i] - (i+1) - c)

print((int(min(res,res2,res3))))
import math

import statistics

N = int(eval(input()))

L = [i for i in map(int,input().split())]

Q = []

for i in range(len(L)):

  Q.append(L[i] - (i+1))

b = statistics.median(Q)

res = 0

for i in range(N):

  res += abs(L[i] - (i+1) - b)

print((int(res)))

import math
import statistics

N = int(eval(input()))
L = [i for i in map(int, input().split())]
Q = []
for i in range(len(L)):
    Q.append(L[i] - (i + 1))
b = statistics.median(Q)
a = b - 1
c = b + 1
res = 0
res2 = 0
res3 = 0
for i in range(N):
    res += abs(L[i] - (i + 1) - b)
    res2 += abs(L[i] - (i + 1) - a)
    res3 += abs(L[i] - (i + 1) - c)
print((int(min(res, res2, res3))))

import math
import statistics

N = int(eval(input()))
L = [i for i in map(int, input().split())]
Q = []
for i in range(len(L)):
    Q.append(L[i] - (i + 1))
b = statistics.median(Q)
res = 0
for i in range(N):
    res += abs(L[i] - (i + 1) - b)
print((int(res)))

-a = b - 1 -c = b + 1 -res2 = 0 -res3 = 0 -    res2 += abs(L[i] - (i + 1) - a) -    res3 += abs(L[i] - (i + 1) - c) -print((int(min(res, res2, res3)))) +print((int(res)))