n = int(input())
a = list(map(int, input().split()))
s = [0 for i in range(n+1)]
sum = 0
for i in range(n):
    sum += a[i]
    s[i+1] = sum
s.sort()
ans = 0
for i in range(1,n+1):
    if s[i] == s[i-1]:
        j = i-1
        while s[i] == s[j]:
            ans += 1
            j -= 1
print(ans)