from math import factorial
import sys
input = sys.stdin.readline
def ncr(n,r):
 if n <= 1:
  return 0
 else:
  return  factorial(n) / factorial(r) / factorial(n - r)

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