n = int(input())
s = list(map(int, input().split()))
count = 0
cl = []
sm = 0
for i in range(n):
  sm+=s[i]
  cl.append(sm)

        
m = set(cl)
st = set(cl)
for x in st:
  t = cl.count(x)
  count+=int(t*(t-1)/2)

count+=cl.count(0)
print(count)