input()
da = list(map(int,input().split()))
al = 0
ta = [0]*len(da)
for i in range(len(da)):
  if i == 0:
    for j in range(len(da)-i):
     ta[j] = sum(da[i:j+1])
     if ta[j] == 0:
      al  += 1
  else:
    for j in range(len(da)-i):
      ta[j+i] -= da[i -1]
      if ta[j+i] == 0:
        al += 1
print(al)