n = int(input())
import numpy as np
li = np.array([ int(it) for it in input().split()])
cs = np.cumsum(li)
import collections
cd = collections.Counter(cs)
sm = 0
for k,v in cd.items():
  p = v - 1 + (1 if k==0 else 0)
  sm += (p*(p+1))//2
print (sm)