n = int(input())
a = list(map(int, input().split()))
A = [0]
for i in range(n):
  A.append(A[-1]+a[i])

ans = A[1:].count(0)
for i in range(1, n-1):
  for j in range(i+1, n):
    if A[i]-A[i-1] + A[j]-A[i] == 0: ans += 1
print(ans)