n = int(input())
a = list(map(int,input().split()))
s = 0
x = {}
x[0] = 1
for i in range(n):
  s += a[i]
  if s not in x.keys():
    x[s] = 1
  else:
    x[s] += 1
ans = 0
for j in x.values():
  ans += j*(j-1)//2
print(ans)
  