n = int(input())
A = [int(i) for i in input().split()]
ans = 0
a = 0
s = [0]*n
for i in range(n):
    a += A[i]
    s[i] = a
    
s = [0]+s

for i in range(1,n):
    for j in range(i+1,n+1):
        if s[j]-s[i-1] == 0:
            ans += 1
        
print(ans)