N=int(input())
A=list(map(int,input().split()))
B=[0]

for i in range(1,N+1):
    B+= [B[i-1]+ A[i-1]]
    #O(n)
temp='a'
ans=0
n=1
B_2 = sorted(B)
#O(nlog(n))
while len(B_2):
    if temp!= B_2[0]:
        temp=B_2.pop(0)
        ans+=int(n*(n-1)/2)
        n=1
    else :
        temp = B_2.pop(0)
        n+=1
if n!=0:
    ans+=int(n*(n-1)/2)
print(ans)
