def slove():

    import sys

    input = sys.stdin.readline

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

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

    b = []

    for i, v in enumerate(a):

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

    b.sort()

    t = b[len(b) // 2]

    s = 0

    for i, v in enumerate(a):

        s += abs(v - (t + (i + 1)))

    print(s)





if __name__ == '__main__':

    slove()

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()

    t1 = 0

    t2 = 0

    for i in range(n):

        t1 += abs(a[i] - a[n//2])

        t2 += abs(a[i] - a[n//2 - 1])

    print((min(t1, t2)))





if __name__ == '__main__':

    solve()

def slove():
    import sys

    input = sys.stdin.readline
    n = int(input().rstrip("\n"))
    a = list(map(int, input().rstrip("\n").split()))
    b = []
    for i, v in enumerate(a):
        b.append(v - (i + 1))
    b.sort()
    t = b[len(b) // 2]
    s = 0
    for i, v in enumerate(a):
        s += abs(v - (t + (i + 1)))
    print(s)


if __name__ == "__main__":
    slove()

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()
    t1 = 0
    t2 = 0
    for i in range(n):
        t1 += abs(a[i] - a[n // 2])
        t2 += abs(a[i] - a[n // 2 - 1])
    print((min(t1, t2)))


if __name__ == "__main__":
    solve()

-def slove(): -    import sys +import sys -    input = sys.stdin.readline -    n = int(input().rstrip("\n")) -    a = list(map(int, input().rstrip("\n").split())) -    b = [] -    for i, v in enumerate(a): -        b.append(v - (i + 1)) -    b.sort() -    t = b[len(b) // 2] -    s = 0 -    for i, v in enumerate(a): -        s += abs(v - (t + (i + 1))) -    print(s) + +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() +    t1 = 0 +    t2 = 0 +    for i in range(n): +        t1 += abs(a[i] - a[n // 2]) +        t2 += abs(a[i] - a[n // 2 - 1]) +    print((min(t1, t2))) -    slove() +    solve()