n = int(input())
A = list(map(int,input().split()))
B = []
def Cumulative_sum(n,A):
  B=[0]
  for i in range(n):
    B.append(A[i] + B[i])
  return B
B = Cumulative_sum(n,A)
ans = 0
B_set = set(B)
for x in B_set:
  count = B.count(x)
  if count > 1:
    ans += (count*(count-1)/2)
print(int(ans))
    

