import collections
n=int(input())
a=list(map(int,input().split()))
c=0
l=[0]
for i in range(n):
  l.append(l[i]+a[i])
l.sort()
L=collections.Counter(l)
for j in range(len(L)):
  x=L.most_common()[j][1]
  c+=int(x*(x-1)/2)
print(c)