def calc_move(As, size): pyramid = [i for i in range(1, size + 1)] + [i for i in range(size - 1, 0, -1)] plus = 0 minus = 0 for a, p in zip(As, pyramid): if a > p: plus += a - p elif a < p: minus += p - a if len(As) > len(pyramid): plus += sum(As[len(pyramid):]) if len(As) < len(pyramid): minus += sum(pyramid[len(As):]) return max(plus, minus) N = int(input()) As = list(map(int, input().split())) min_move = sum(As) - 1 max_size = int(sum(As)**0.5) for size in range(2, max_size + 1): move = calc_move(As, size) if move < min_move: min_move = move print(min_move)