import collections

#n=int(input())
#a=list(map(int,input().split(" ")))
n=5
a=[1,-2,3,-4,5]
b=[0 for i in range(n+1)]
s=[0 for i in range(n+1)]
for i in range(1,n+1):
  s[i]=s[i-1]+a[i-1]
c=collections.Counter(s).most_common()
d=0
for i in c:
  if i[1]<2:
    break
  d+=i[1]*(i[1]-1)//2
print(d)