N = int(input())
S = list(map(int,input().split()))


ans = 0
S.insert(0,"0")
for i in range(N):
    count = []
    S.pop(0)
    for j in S:
        count.append(j)
        if sum(count) == 0:
            ans += 1
    
print(ans)