N = int(raw_input())
A = map(long, raw_input().split())
ans = 0
s = 0L
S = [0L]
for a in A:
  s += a
  S.append(s)
S.sort()
c = S[0]
n = 1
for s in S[1:]:
  if c == s:
    n += 1
  else:
    ans += n*(n-1)/2
    n = 1
    c = s
ans += n*(n-1)/2
#for i in range(N):
#  for j in range(N+1)[i+1:]:
#    if sum(A[i:j]) == 0:
#      ans += 1
print ans
