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