N = int(input()) A = list(map(int, input().split())) s = sum(A) ans = 100*100+10 max_height = int(s**0.5) max_bottom = 2* max_height - 1 for bottom in range(1, max_bottom+1, 2): plus = 0 for i in range(max(N, bottom)): if i < bottom: h = bottom -i if i > bottom // 2 else i + 1 else: h = 0 if i < N and A[i] > h: plus += A[i] - h ans = min(ans, plus) print(ans)