from statistics import median



n = eval(input())

a = input().split()

a = list(map(int, a))



b = []



for i, v in enumerate(a):

    b.append(v - (i + 1))



median = int(median(b))



c = 0



for v in b:

    c = c + abs(v - median)



print(c)

from statistics import median



n = eval(input())

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



b = [v - (i + 1) for i, v in enumerate(a)]



median = int(median(b))



c = sum(abs(v - median) for v in b)



print(c)

from statistics import median

n = eval(input())
a = input().split()
a = list(map(int, a))
b = []
for i, v in enumerate(a):
    b.append(v - (i + 1))
median = int(median(b))
c = 0
for v in b:
    c = c + abs(v - median)
print(c)

from statistics import median

n = eval(input())
a = list(map(int, input().split()))
b = [v - (i + 1) for i, v in enumerate(a)]
median = int(median(b))
c = sum(abs(v - median) for v in b)
print(c)

-a = input().split() -a = list(map(int, a)) -b = [] -for i, v in enumerate(a): -    b.append(v - (i + 1)) +a = list(map(int, input().split())) +b = [v - (i + 1) for i, v in enumerate(a)] -c = 0 -for v in b: -    c = c + abs(v - median) +c = sum(abs(v - median) for v in b)