n = int( raw_input() )
a = map(int, raw_input().split())

used = [False] * n
ans = 0
for i in range(0, n-1):
    s = a[i]
    for j in range(i+1, n):
        s += a[j]
        if s == 0:
            ans += 1
            used[j] = True

if used[n-1]:
    print ans
else:
    print 0