from math import factorial
def ncr(n,r):
  return (factorial(n) // factorial(r) // factorial(n - r))

n= int(input())
a = list(int(i) for i in input().split())
s = [0]
tp = 0
for i in a:
  tp += i
  s.append(tp)
s.sort()
ans = 0
for i in range(n):
  if s[i] == s[i+1]:
    ans += 1
print(ncr(ans,2))