import collections

n=int(input())
*a,=map(int,input().split())
 
b=[0]
 
for i in range(n):
  b.append(a[i]+b[i])
 
L=collections.Counter(b)

ans=0
for i in L.values():
      if i>1:
            ans+=i*(i-1)//2
print(ans)
