from collections import Counter
MOD=1000000007
def modpow(a,n,mod):
    res=1
    a=a%mod
    while(n>0):
        if(n&1):
            res=res*a%mod
        a=a*a%mod
        n>>=1
    return res

def com(n,k,mod):
    res=1
    tmp=1
    for i in range(1,k+1):
        res=res*(n-i+1)%mod
        tmp=tmp*i%mod
    a=modpow(tmp,1000000005,mod)
    return res*a%mod

N=int(input())
a=list(map(int,input().split()))
sli=[0]
tmp=0
for i in range(N):
    tmp+=a[i]
    sli.append(tmp)
c=Counter(sli).most_common()
ans=0
for z,x in c:
    ans+=com(x,2,MOD)
print(ans)