import sys

sys.setrecursionlimit(1 << 25)

read = sys.stdin.readline

ra = range

enu = enumerate





def read_ints():

    return list(map(int, read().split()))





def read_a_int():

    return int(read())





def read_tuple(H):

    '''

    H is number of rows

    '''

    ret = []

    for _ in range(H):

        ret.append(tuple(map(int, read().split())))

    return ret





def read_col(H):

    '''

    H is number of rows

    A列、B列が与えられるようなとき

    ex1)A,B=read_col(H)    ex2) A,=read_col(H) #一列の場合

    '''

    ret = []

    for _ in range(H):

        ret.append(list(map(int, read().split())))

    return tuple(map(list, list(zip(*ret))))





def read_matrix(H):

    '''

    H is number of rows

    '''

    ret = []

    for _ in range(H):

        ret.append(list(map(int, read().split())))

    return ret

    # return [list(map(int, read().split())) for _ in range(H)] # 内包表記はpypyでは遅いため





MOD = 10**9 + 7

INF = 2**31  # 2147483648 > 10**9

# default import

from collections import defaultdict, Counter, deque

from operator import itemgetter

from itertools import product, permutations, combinations

from bisect import bisect_left, bisect_right  # , insort_left, insort_right



# https://atcoder.jp/contests/arc100/tasks/arc100_a



N = read_a_int()

A = read_ints()

# Ai-iをBiとする

# Σ|Bi - b|を最小化するはBiの中央値(ということを経験的に知っている)(二部探索してみればいいこと)



B = []

for i, a in enu(A, start=1):

    B.append(a - i)

import numpy as np

b = np.median(B)

ans = 0

print((int(np.abs(np.array(B) - b).sum())))

import sys

sys.setrecursionlimit(1 << 25)

readline = sys.stdin.buffer.readline

read = sys.stdin.readline  # 文字列読み込む時はこっち



import numpy as np

from functools import partial

array = partial(np.array, dtype=np.int64)

zeros = partial(np.zeros, dtype=np.int64)

full = partial(np.full, dtype=np.int64)



ra = range

enu = enumerate





def exit(*argv, **kwarg):

    print(*argv, **kwarg)

    sys.exit()





def mina(*argv, sub=1): return list(map(lambda x: x - sub, argv))

# 受け渡されたすべての要素からsubだけ引く.リストを*をつけて展開しておくこと





def a_int(): return int(readline())





def ints(): return np.fromstring(readline(), sep=' ', dtype=np.int64)





def read_matrix(H, W):

    '''return np.ndarray shape=(H,W) matrix'''

    lines = []

    for _ in range(H):

        lines.append(read())

    lines = ' '.join(lines)  # byte同士の結合ができないのでreadlineでなくreadで

    return np.fromstring(lines, sep=' ', dtype=np.int64).reshape(H, W)





def read_col(H):

    '''H is number of rows

    A列、B列が与えられるようなとき

    ex1)A,B=read_col(H)    ex2) A,=read_col(H) #一列の場合'''

    ret = []

    for _ in range(H):

        ret.append(list(map(int, readline().split())))

    return tuple(map(list, zip(*ret)))





def read_tuple(H):

    '''H is number of rows'''

    ret = []

    for _ in range(H):

        ret.append(tuple(map(int, readline().split())))

    return ret





MOD = 10**9 + 7

INF = 2**31  # 2147483648 > 10**9

# default import



from collections import defaultdict, Counter, deque

from operator import itemgetter, xor, add

from itertools import product, permutations, combinations

from bisect import bisect_left, bisect_right  # , insort_left, insort_right

from functools import reduce

from math import gcd





def lcm(a, b):

    # 最小公倍数

    g = gcd(a, b)

    return a // g * b





N = a_int()

A = ints()

B = A - np.arange(1, N + 1)

b = int(np.median(B))

print(np.abs(B - b).sum())

import sys

sys.setrecursionlimit(1 << 25)
read = sys.stdin.readline
ra = range
enu = enumerate


def read_ints():
    return list(map(int, read().split()))


def read_a_int():
    return int(read())


def read_tuple(H):
    """
    H is number of rows
    """
    ret = []
    for _ in range(H):
        ret.append(tuple(map(int, read().split())))
    return ret


def read_col(H):
    """
    H is number of rows
    A列、B列が与えられるようなとき
    ex1)A,B=read_col(H)    ex2) A,=read_col(H) #一列の場合
    """
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return tuple(map(list, list(zip(*ret))))


def read_matrix(H):
    """
    H is number of rows
    """
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return ret
    # return [list(map(int, read().split())) for _ in range(H)] # 内包表記はpypyでは遅いため


MOD = 10**9 + 7
INF = 2**31  # 2147483648 > 10**9
# default import
from collections import defaultdict, Counter, deque
from operator import itemgetter
from itertools import product, permutations, combinations
from bisect import bisect_left, bisect_right  # , insort_left, insort_right

# https://atcoder.jp/contests/arc100/tasks/arc100_a
N = read_a_int()
A = read_ints()
# Ai-iをBiとする
# Σ|Bi - b|を最小化するはBiの中央値(ということを経験的に知っている)(二部探索してみればいいこと)
B = []
for i, a in enu(A, start=1):
    B.append(a - i)
import numpy as np

b = np.median(B)
ans = 0
print((int(np.abs(np.array(B) - b).sum())))

import sys

sys.setrecursionlimit(1 << 25)
readline = sys.stdin.buffer.readline
read = sys.stdin.readline  # 文字列読み込む時はこっち
import numpy as np
from functools import partial

array = partial(np.array, dtype=np.int64)
zeros = partial(np.zeros, dtype=np.int64)
full = partial(np.full, dtype=np.int64)
ra = range
enu = enumerate


def exit(*argv, **kwarg):
    print(*argv, **kwarg)
    sys.exit()


def mina(*argv, sub=1):
    return list(map(lambda x: x - sub, argv))


# 受け渡されたすべての要素からsubだけ引く.リストを*をつけて展開しておくこと
def a_int():
    return int(readline())


def ints():
    return np.fromstring(readline(), sep=" ", dtype=np.int64)


def read_matrix(H, W):
    """return np.ndarray shape=(H,W) matrix"""
    lines = []
    for _ in range(H):
        lines.append(read())
    lines = " ".join(lines)  # byte同士の結合ができないのでreadlineでなくreadで
    return np.fromstring(lines, sep=" ", dtype=np.int64).reshape(H, W)


def read_col(H):
    """H is number of rows
    A列、B列が与えられるようなとき
    ex1)A,B=read_col(H)    ex2) A,=read_col(H) #一列の場合"""
    ret = []
    for _ in range(H):
        ret.append(list(map(int, readline().split())))
    return tuple(map(list, zip(*ret)))


def read_tuple(H):
    """H is number of rows"""
    ret = []
    for _ in range(H):
        ret.append(tuple(map(int, readline().split())))
    return ret


MOD = 10**9 + 7
INF = 2**31  # 2147483648 > 10**9
# default import
from collections import defaultdict, Counter, deque
from operator import itemgetter, xor, add
from itertools import product, permutations, combinations
from bisect import bisect_left, bisect_right  # , insort_left, insort_right
from functools import reduce
from math import gcd


def lcm(a, b):
    # 最小公倍数
    g = gcd(a, b)
    return a // g * b


N = a_int()
A = ints()
B = A - np.arange(1, N + 1)
b = int(np.median(B))
print(np.abs(B - b).sum())

-read = sys.stdin.readline +readline = sys.stdin.buffer.readline +read = sys.stdin.readline  # 文字列読み込む時はこっち +import numpy as np +from functools import partial + +array = partial(np.array, dtype=np.int64) +zeros = partial(np.zeros, dtype=np.int64) +full = partial(np.full, dtype=np.int64) -def read_ints(): -    return list(map(int, read().split())) +def exit(*argv, **kwarg): +    print(*argv, **kwarg) +    sys.exit() -def read_a_int(): -    return int(read()) +def mina(*argv, sub=1): +    return list(map(lambda x: x - sub, argv)) + + +# 受け渡されたすべての要素からsubだけ引く.リストを*をつけて展開しておくこと +def a_int(): +    return int(readline()) + + +def ints(): +    return np.fromstring(readline(), sep=" ", dtype=np.int64) + + +def read_matrix(H, W): +    """return np.ndarray shape=(H,W) matrix""" +    lines = [] +    for _ in range(H): +        lines.append(read()) +    lines = " ".join(lines)  # byte同士の結合ができないのでreadlineでなくreadで +    return np.fromstring(lines, sep=" ", dtype=np.int64).reshape(H, W) + + +def read_col(H): +    """H is number of rows +    A列、B列が与えられるようなとき +    ex1)A,B=read_col(H)    ex2) A,=read_col(H) #一列の場合""" +    ret = [] +    for _ in range(H): +        ret.append(list(map(int, readline().split()))) +    return tuple(map(list, zip(*ret))) -    """ -    H is number of rows -    """ +    """H is number of rows""" -        ret.append(tuple(map(int, read().split()))) +        ret.append(tuple(map(int, readline().split()))) - - -def read_col(H): -    """ -    H is number of rows -    A列、B列が与えられるようなとき -    ex1)A,B=read_col(H)    ex2) A,=read_col(H) #一列の場合 -    """ -    ret = [] -    for _ in range(H): -        ret.append(list(map(int, read().split()))) -    return tuple(map(list, list(zip(*ret)))) - - -def read_matrix(H): -    """ -    H is number of rows -    """ -    ret = [] -    for _ in range(H): -        ret.append(list(map(int, read().split()))) -    return ret -    # return [list(map(int, read().split())) for _ in range(H)] # 内包表記はpypyでは遅いため -from operator import itemgetter +from operator import itemgetter, xor, add +from functools import reduce +from math import gcd -# https://atcoder.jp/contests/arc100/tasks/arc100_a -N = read_a_int() -A = read_ints() -# Ai-iをBiとする -# Σ|Bi - b|を最小化するはBiの中央値(ということを経験的に知っている)(二部探索してみればいいこと) -B = [] -for i, a in enu(A, start=1): -    B.append(a - i) -import numpy as np -b = np.median(B) -ans = 0 -print((int(np.abs(np.array(B) - b).sum()))) +def lcm(a, b): +    # 最小公倍数 +    g = gcd(a, b) +    return a // g * b + + +N = a_int() +A = ints() +B = A - np.arange(1, N + 1) +b = int(np.median(B)) +print(np.abs(B - b).sum())