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):
  for j in range(i+1,N):
    if (L[i] - L[j] == 0):
        k += 1
p = L.count(0)
print(k+p)