n = int(input())
A = list(map(int,input().split()))
S = []
sm = 0
ans=0
for a in A:
    sm += a
    S.append(sm)
S.sort()
for s in S:
    if S[s]==0:
        ans+=1
        F=S.count(0)
        for i in range(1,F):
            F=F*i
        pro=F/2
        ans=ans+pro
        pro=0
    else:
        
        for s in range(1,S[n]+1):
            C=S.count(s)
            if C>1:
                
                for i in range(1,C):
                    C=C*i
                pro=C/2
                ans=ans+pro
                pro=0
print(ans)
        