input()
da = list(map(int,input().split()))
al = 0
ta = [0]*len(da)
for i in range(len(da)):
  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
print(al)