import numpy as np

N = int(input())
A = [i for i in map(int, input().split())]

count = 0
numbers = np.array([])
for i in A:
    numbers = numbers + i
    numbers = np.append(numbers, i)
    count += np.sum(numbers == 0)

print(count)