def 解():

    iN = int(eval(input()))

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

    aA = sorted(map(lambda x,y:x-y,aA,list(range(1,iN+1))))

    iL = len(aA)

    if iL % 2 :

        iMed = aA[(iL-1)//2]

    else:

        iMed = aA[iL//2]

    iMean = sum(aA) // 2

    iBlim= min(iMed,iMean)

    iUlim= min(iMed,iMean+1)



    print((min(sum(abs(a-i) for a in aA) for i in [iMed,iMean,iMean+1])))



解()

def 解():

    iN = int(eval(input()))

    #aA = map(int,input().split())

    aA = sorted(map(lambda x,y:x-y,list(map(int,input().split())),list(range(1,iN+1))))

    iL = len(aA)

    if iL % 2 :

        iMed = aA[(iL-1)//2]

    else:

        iMed = aA[iL//2]

    print((sum(abs(a-iMed) for a in aA)))



解()

def 解():
    iN = int(eval(input()))
    aA = list(map(int, input().split()))
    aA = sorted(map(lambda x, y: x - y, aA, list(range(1, iN + 1))))
    iL = len(aA)
    if iL % 2:
        iMed = aA[(iL - 1) // 2]
    else:
        iMed = aA[iL // 2]
    iMean = sum(aA) // 2
    iBlim = min(iMed, iMean)
    iUlim = min(iMed, iMean + 1)
    print((min(sum(abs(a - i) for a in aA) for i in [iMed, iMean, iMean + 1])))


解()

def 解():
    iN = int(eval(input()))
    # aA = map(int,input().split())
    aA = sorted(
        map(lambda x, y: x - y, list(map(int, input().split())), list(range(1, iN + 1)))
    )
    iL = len(aA)
    if iL % 2:
        iMed = aA[(iL - 1) // 2]
    else:
        iMed = aA[iL // 2]
    print((sum(abs(a - iMed) for a in aA)))


解()

-    aA = list(map(int, input().split())) -    aA = sorted(map(lambda x, y: x - y, aA, list(range(1, iN + 1)))) +    # aA = map(int,input().split()) +    aA = sorted( +        map(lambda x, y: x - y, list(map(int, input().split())), list(range(1, iN + 1))) +    ) -    iMean = sum(aA) // 2 -    iBlim = min(iMed, iMean) -    iUlim = min(iMed, iMean + 1) -    print((min(sum(abs(a - i) for a in aA) for i in [iMed, iMean, iMean + 1]))) +    print((sum(abs(a - iMed) for a in aA)))