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):
      if j == 0:
        ta[0] = da[i]
      else:
        ta[j] = ta[j-1] + da[i+j]
      if ta[j] == 0:
        al += 1
  else:
    for j in range(len(da)-i):
      ta[j+i] -= da[j-1]
      if ta[j+i] == 0:
        al += 1
print(al)