N = int(input())
a = list(map(int, input().split()))
s = list()
s.append(0)
for i in range(N):
  s.append(a[i] + s[i])
b = sorted(s)
c = len(b)
count = 0
for j in range(c):
  d = b.count(b[j])
  count += (d * (d-1))/2/d
print(int(count))