INF = 1<<32 M = 200 N = int(input()) A = list(map(int,input().split())) ans = INF for X in range(M): for Len in range(1,M,2): if X + Len > M: break P = [0] * M cnt = 1 Mid = Len // 2 for i in range(Len): P[X+i] = cnt if i < Mid: cnt += 1 else: cnt -= 1 for Y in range(M): if Y + N > M: break Q = [0] * M for i in range(N): Q[Y+i] = A[i] ret = 0 cnt = 0 for i in range(M): if P[i] < Q[i]: ret += Q[i] - P[i] cnt += Q[i] - P[i] else: cnt -= P[i] - Q[i] if cnt < 0: ret += INF ans = min(ans, ret) print(ans)