D = {0: 1}
N = int(input())
A = list(map(int, input().split()))
S = 0
for i in range(N):
  S += A[i]
  if S in D:
    D[S] += 1
  else:
    D[S] = 1
p = 0
for i in D:
  p += (D[i] * (D[i] - 1)) // 2
print(p)