n=int(input())
s=input().split()
l=[int(i) for i in s]
ll=[0 for i in range(n)]
ll[0]=l[0]
for i in range(1,n):
    ll[i]=ll[i-1]+l[i]
ll=[0]+ll
ll.sort()
now=ll[0]
cnt=1
res=0
for i in range(1,n+1):
    if ll[i]==now:
        cnt+=1
    else:
        if i==n:
            break
        res+=cnt*(cnt-1)//2
        cnt=1
        now=ll[i+1]
res+=cnt*(cnt-1)//2
print(res)