def P(x):
    ans=1
    for i in range(x):
        ans=ans*(i+1)
    
    return(ans)

def comb(n, r):
    return P(n)//(P(n - r)*P(r))

n = int(input())
a=list(map(int,input().split()))

c=[0]*(n+1)

c[0]=a[0]

for i in range(1,n):
    c[i]=c[i-1]+a[i]


c.sort()

#print(c)

now=c[0]
t=1
ans=0

for i in range(1,n+1):
    if c[i]==now:
        t+=1
    else:
        now=c[i]
        if t>1:
            ans+=comb(t,2)
        t=1
else:
    now=c[i]
    if t>1:
        ans+=comb(t,2)
    
print(ans)
