# coding: utf-8
# Your code here!
N=int(input())
A=list(map(int,input().split()))
l=[0]*N

for i in range(N):
    l[i]=l[i-1]+A[i]

ans=0    
for i in range(N):
    ans+=l[i:].count(0)
    l=list(map(lambda x:x-A[i],l))

print(ans)
    

