from statistics import median



N = int(eval(input()))

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



A_star = [a - (i + 1) for i, a in enumerate(A)]



def calc_score(b):

    score = 0

    for a in A_star:

        score += abs(a - b)

    return score



def decide_direction(b):

    score0 = calc_score(b)

    score1 = calc_score(b + 1)

    if score0 > score1:

        return 1

    else:

        return -1



b = int(median(A_star))

direction = decide_direction(b)

pre_score = calc_score(b)



while True:

    b += direction

    score = calc_score(b)

    if score >= pre_score:

        print(pre_score)

        break

    else:

        pre_score = score









from statistics import median



N = int(eval(input()))

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



A_star = [a - (i + 1) for i, a in enumerate(A)]



def calc_score(b):

    score = 0

    for a in A_star:

        score += abs(a - b)

    return score



print((calc_score(int(median(A_star)))))
from statistics import median

N = int(eval(input()))
A = list(map(int, input().split()))
A_star = [a - (i + 1) for i, a in enumerate(A)]


def calc_score(b):
    score = 0
    for a in A_star:
        score += abs(a - b)
    return score


def decide_direction(b):
    score0 = calc_score(b)
    score1 = calc_score(b + 1)
    if score0 > score1:
        return 1
    else:
        return -1


b = int(median(A_star))
direction = decide_direction(b)
pre_score = calc_score(b)
while True:
    b += direction
    score = calc_score(b)
    if score >= pre_score:
        print(pre_score)
        break
    else:
        pre_score = score

from statistics import median

N = int(eval(input()))
A = list(map(int, input().split()))
A_star = [a - (i + 1) for i, a in enumerate(A)]


def calc_score(b):
    score = 0
    for a in A_star:
        score += abs(a - b)
    return score


print((calc_score(int(median(A_star)))))

-def decide_direction(b): -    score0 = calc_score(b) -    score1 = calc_score(b + 1) -    if score0 > score1: -        return 1 -    else: -        return -1 - - -b = int(median(A_star)) -direction = decide_direction(b) -pre_score = calc_score(b) -while True: -    b += direction -    score = calc_score(b) -    if score >= pre_score: -        print(pre_score) -        break -    else: -        pre_score = score +print((calc_score(int(median(A_star)))))