from collections import deque
a = int(input())
b = [int(i) for i in input().split()]
c = deque(b)
e = deque(b)
sum = 0
d = 0
for x in c:
    sum = x
    e.popleft()
    for y in e:
        sum += y
        if sum == 0:
            d += 1

print(d)