N = int(input())
A = list(map(int,input().split()))
L = [A[0]]
for i in range(1,N):
  L.append(L[i-1]+A[i])
k = 0
for i in range(N):
  if (L[i] == 0):
    k += 1
  for j in range(i+1,N):
    if (L[i] - L[j] == 0):
      k += 1
print(k)