n=int(input())
l=list(map(int,input().split()))
r[0]*(n+1)
for i in range(n):
    r[i+1]=r[i]+l[i]
r.sort()
r.append(100000000000)
f=1
ans=0
for i in range(n+1):
    if r[i]==r[i+1]:
        f+=1
    else:
        ans+=f*(f-1)//2
        f=1
print(ans)