def main():

    from statistics import median



    n, *a, = list(map(int, open(0).read().split()))

    a = [x - i for i, x in enumerate(a, 1)]

    a.sort()

    m = int(median(a))



    ans = sum([abs(x - m) for x in a])

    print(ans)





if __name__ == '__main__':

    main()

def main():

    n, *a, = list(map(int, open(0).read().split()))

    a = [x - i for i, x in enumerate(a, 1)]

    a.sort()

    if n % 2 == 0:

        ans = sum(a[n // 2:]) - sum(a[:n // 2])

    else:

        ans = sum(a[n // 2 + 1:]) - sum(a[:n // 2])

    print(ans)





if __name__ == '__main__':

    main()

def main():
    from statistics import median

    (
        n,
        *a,
    ) = list(map(int, open(0).read().split()))
    a = [x - i for i, x in enumerate(a, 1)]
    a.sort()
    m = int(median(a))
    ans = sum([abs(x - m) for x in a])
    print(ans)


if __name__ == "__main__":
    main()

def main():
    (
        n,
        *a,
    ) = list(map(int, open(0).read().split()))
    a = [x - i for i, x in enumerate(a, 1)]
    a.sort()
    if n % 2 == 0:
        ans = sum(a[n // 2 :]) - sum(a[: n // 2])
    else:
        ans = sum(a[n // 2 + 1 :]) - sum(a[: n // 2])
    print(ans)


if __name__ == "__main__":
    main()

-    from statistics import median - -    m = int(median(a)) -    ans = sum([abs(x - m) for x in a]) +    if n % 2 == 0: +        ans = sum(a[n // 2 :]) - sum(a[: n // 2]) +    else: +        ans = sum(a[n // 2 + 1 :]) - sum(a[: n // 2])