n=int(input())
a=list(map(int,input().split(" ")))
#n=6
#a=[1,3,-4,2,2,-2]
c=0
s=[0 for i in range(n+1)]
for i in range(1,n+1):
  s[i]=s[i-1]+a[i-1]
for i in range(n):
  for j in range(i+1,n+1):
    if (s[j]-s[i])==0:
      c+=1
print(c)