import math N = int(input()) A = list(map(int, input().split())) total = sum(A) tall = int(math.sqrt(total)) ans = 0 for i in range(N): ans += max(0, A[i] - max(0, tall - abs((tall - 1) - i))) print(ans)