from itertools import accumulate as ac
from collections import Counter
n=int(input())
o=Counter(ac(map(int,input().split())))
cd=[i for i in o.items() if (i[0]==0 and i[1]>=1) or (i[1]%2==0 and i[1]>0)]

v=0

for i in cd:
  if i[0]==0:
    v+=i[1]
    if i[1]>=2:
      v+=(i[1]*(i[1]-1)//2)
  else:
    v+=(i[1]*(i[1]-1)//2)

print(v)