N=int(input())
A=list(map(int,input().split()))
B=[]
count=0
answer=0

for i in range(len(A)):
  count+=A[i]
  B.append(count)
  if count==0:
    answer+=1

for i in range(len(B)-1):
  x=A[i]
  for j in range(i+1,len(B)):
   B[j]-=x
   if B[j]==0:
      answer+=1

print(answer)