#agc023a

n=int(raw_input())
a=map(int,raw_input().split())
s=[0]
for i in xrange(n):
 s.append(s[i]+a[i])
b={}
for i in s:
 if i not in b:
  b[i]=1
 else:
  b[i]+=1
res=0
for i in b:
 res+=b[i]*(b[i]-1)/2
print res
