import sys





def solve():

    input = sys.stdin.readline

    mod = 10 ** 9 + 7

    n = int(input().rstrip('\n'))

    a = list(map(int, input().rstrip('\n').split()))

    for i in range(n):

        a[i] -= i + 1

    a.sort()

    t = a[n // 2]

    mt = 0

    for v in a:

        mt += abs(t - v)

    print(mt)





if __name__ == '__main__':

    solve()

import sys





def solve():

    readline = sys.stdin.buffer.readline

    mod = 10 ** 9 + 7

    n = int(readline())

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

    for i in range(n):

        a[i] -= i + 1

    a.sort()

    t = 0

    for v in a:

        t += abs(a[n // 2] - v)

    print(t)





if __name__ == '__main__':

    solve()

import sys


def solve():
    input = sys.stdin.readline
    mod = 10**9 + 7
    n = int(input().rstrip("\n"))
    a = list(map(int, input().rstrip("\n").split()))
    for i in range(n):
        a[i] -= i + 1
    a.sort()
    t = a[n // 2]
    mt = 0
    for v in a:
        mt += abs(t - v)
    print(mt)


if __name__ == "__main__":
    solve()

import sys


def solve():
    readline = sys.stdin.buffer.readline
    mod = 10**9 + 7
    n = int(readline())
    a = list(map(int, readline().split()))
    for i in range(n):
        a[i] -= i + 1
    a.sort()
    t = 0
    for v in a:
        t += abs(a[n // 2] - v)
    print(t)


if __name__ == "__main__":
    solve()

-    input = sys.stdin.readline +    readline = sys.stdin.buffer.readline -    n = int(input().rstrip("\n")) -    a = list(map(int, input().rstrip("\n").split())) +    n = int(readline()) +    a = list(map(int, readline().split())) -    t = a[n // 2] -    mt = 0 +    t = 0 -        mt += abs(t - v) -    print(mt) +        t += abs(a[n // 2] - v) +    print(t)