n = int(input())
A = [int(i) for i in input().split()]
ans = 0


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