import sys
from collections import defaultdict as dd
from bisect import bisect_left as bl
input = sys.stdin.readline
N = int(input())
A = list(map(int, input().split()))
cs = [0] * (N + 1)
d = dd(list)
res = 0
for i in range(N):
  cs[i + 1] = cs[i] + A[i]
for i in range(1, N + 1):
  d[cs[i]].append(i - 1)
for i in range(N):
  x = bl(d[cs[i]], i + 1)
  res += max(len(d[cs[i]]) - x, 0)
  #print(res, cs[i], x, len(d[cs[i]]))
#print(d)
#print(cs)
print(res)