n = int(input()) a_list = list(map(int, input().split())) block_sum = sum(a_list) required = 1 count = 0 for i in range(1, 51): tmp = required + 2 * i + 1 if tmp > block_sum: count = i break required = tmp result = 0 for i in range(1, n + 1): if i >= count * 2: result += a_list[i-1] elif i > count: result += max(a_list[i-1] - (count * 2 - i), 0) else: result += max(a_list[i-1] - i, 0) print(result)