n=int(input())
a=list(map(int,input().split()))
s=[0]
ans=0
for i in range(n):
    S=s[i]+a[i]
    s.append(S)
tmp=list(set(s))
for i in range(len(tmp)):
    C=s.count(tmp[i])
    ans+=C*(C-1)//2
print(ans)