import sys

from collections import deque

from collections import  Counter

import statistics

import math

stdin = sys.stdin



ni = lambda: int(ns())

na = lambda: list(map(int, stdin.readline().split()))

ns = lambda: stdin.readline()



n = ni()

a_li = na()

for i in range(n):

    a_li[i] = a_li[i] - (i + 1)

m1 = statistics.median_low(a_li)

m2 = statistics.median_high(a_li)

ans1 = 0

ans2 = 0

for i in range(n):

    ans1 += abs(a_li[i] - m1)

    ans2 += abs(a_li[i] - m2)

print((min(ans1, ans2)))

import sys

from collections import deque

from collections import  Counter

import statistics

import math

stdin = sys.stdin



ni = lambda: int(ns())

na = lambda: list(map(int, stdin.readline().split()))

ns = lambda: stdin.readline()



n = ni()

a_li = na()

for i in range(n):

    a_li[i] = a_li[i] - (i + 1)

m1 = statistics.median_low(a_li)

#m2 = statistics.median_high(a_li)

ans1 = 0

#ans2 = 0

for i in range(n):

    ans1 += abs(a_li[i] - m1)

    #ans2 += abs(a_li[i] - m2)

print(ans1)

import sys
from collections import deque
from collections import Counter
import statistics
import math

stdin = sys.stdin
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline()
n = ni()
a_li = na()
for i in range(n):
    a_li[i] = a_li[i] - (i + 1)
m1 = statistics.median_low(a_li)
m2 = statistics.median_high(a_li)
ans1 = 0
ans2 = 0
for i in range(n):
    ans1 += abs(a_li[i] - m1)
    ans2 += abs(a_li[i] - m2)
print((min(ans1, ans2)))

import sys
from collections import deque
from collections import Counter
import statistics
import math

stdin = sys.stdin
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline()
n = ni()
a_li = na()
for i in range(n):
    a_li[i] = a_li[i] - (i + 1)
m1 = statistics.median_low(a_li)
# m2 = statistics.median_high(a_li)
ans1 = 0
# ans2 = 0
for i in range(n):
    ans1 += abs(a_li[i] - m1)
    # ans2 += abs(a_li[i] - m2)
print(ans1)

-m2 = statistics.median_high(a_li) +# m2 = statistics.median_high(a_li) -ans2 = 0 +# ans2 = 0 -    ans2 += abs(a_li[i] - m2) -print((min(ans1, ans2))) +    # ans2 += abs(a_li[i] - m2) +print(ans1)