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
dic={}
for i in ll:
    if i not in dic.keys():
        dic[i]=1
    else:
        dic[i]+=1
res=0
for i in dic.keys():
    res+=dic[i]*(dic[i]-1)//2
print(res)
