n=int(input())
a=list(map(int,input().split()))
b=[]
for i in range(n):
  if i==0:
    b.append(a[0])
  else:
    b.append(b[-1]+a[i])
ans = b.count(0)
bp = [i for i in b if i>0]
bm = [i for i in b if i<0]
for i in bp:
  ans += bm.count(-i)
print(ans)