n = int(input())
a = list(map(int, input().split()))

l = [0 for i in range(n+1)]
for i in range(1, n+1):
  l[i] = l[i-1] + a[i-1]
  
ans = 0
for i in range(2, n):
  for j in range(i, n+1):
    if l[j] == l[j-i]:
      ans += 1
print(ans)
