n=int(input())
A=list(map(int,input().split()))
s=[0]
for i in range(n):
    s.append(s[-1]+A[i])
cnt=0
for i in range(n):
    for j in range(i+1,n+1):
        if s[i]==s[j]:
            cnt+=1
print(cnt)
