n=int(input())
arr=list(map(int,input().split()))
acum=[0]*(n+1)
acum[1]=arr[0]
cnt=0
for i in range(2,n+1):
  acum[i]=acum[i-1]+arr[i-1]
for i in range(n):
  for j in range(1,n-i+1):
    if acum[i+j]-acum[i]==0:
      cnt+=1
print(cnt)