# -*- coding: utf-8 -*-

# AtCoder Beginner Contest





if __name__ == '__main__':

    from statistics import median



    n = int(eval(input()))

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

    total = 0



    # See:

    # https://www.youtube.com/watch?v=UX4AuiCVtN4

    # https://beta.atcoder.jp/contests/abc102/submissions/2768315

    mod_a = sorted([ai - i for i, ai in enumerate(a, 1)])

    b = median(mod_a)



    for i in range(n):

        total += abs(mod_a[i] - b)



    print((int(total)))

# -*- coding: utf-8 -*-





def main():

    from statistics import median



    n = int(eval(input()))

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

    mod_a = list()

    ans = 0



    for index, ai in enumerate(a, 1):

        mod_a.append(ai - index)



    b = int(median(mod_a))



    for mod_ai in mod_a:

        ans += abs(mod_ai - b)



    print(ans)





if __name__ == '__main__':

    main()

# -*- coding: utf-8 -*-
# AtCoder Beginner Contest
if __name__ == "__main__":
    from statistics import median

    n = int(eval(input()))
    a = list(map(int, input().split()))
    total = 0
    # See:
    # https://www.youtube.com/watch?v=UX4AuiCVtN4
    # https://beta.atcoder.jp/contests/abc102/submissions/2768315
    mod_a = sorted([ai - i for i, ai in enumerate(a, 1)])
    b = median(mod_a)
    for i in range(n):
        total += abs(mod_a[i] - b)
    print((int(total)))

# -*- coding: utf-8 -*-
def main():
    from statistics import median

    n = int(eval(input()))
    a = list(map(int, input().split()))
    mod_a = list()
    ans = 0
    for index, ai in enumerate(a, 1):
        mod_a.append(ai - index)
    b = int(median(mod_a))
    for mod_ai in mod_a:
        ans += abs(mod_ai - b)
    print(ans)


if __name__ == "__main__":
    main()

-# AtCoder Beginner Contest -if __name__ == "__main__": +def main(): -    total = 0 -    # See: -    # https://www.youtube.com/watch?v=UX4AuiCVtN4 -    # https://beta.atcoder.jp/contests/abc102/submissions/2768315 -    mod_a = sorted([ai - i for i, ai in enumerate(a, 1)]) -    b = median(mod_a) -    for i in range(n): -        total += abs(mod_a[i] - b) -    print((int(total))) +    mod_a = list() +    ans = 0 +    for index, ai in enumerate(a, 1): +        mod_a.append(ai - index) +    b = int(median(mod_a)) +    for mod_ai in mod_a: +        ans += abs(mod_ai - b) +    print(ans) + + +if __name__ == "__main__": +    main()