n=int(input())
a=list(map(int,input().split()))

sums=[0]*(len(a)+1)
for i in range(len(a)):
  sums[i+1]=sums[i]+a[i]
  
cnt=0
for i in range(len(sums)-1):
  for j in range(i+1,len(sums)):
    if sums[j]-sums[i]==0:
      cnt+=1
      
print(cnt)