n = int(input())
a = list(map(int, input().split()))
A = [0]
for i in range(n):
  A.append(A[-1]+a[i])
ans = 0
for i in range(n):
  x = [j for j in A[i+1:] if j==A[i]]
  if len(x) > 0: ans += len(x)
print(ans)