from collections import Counter
n = int(input())
lis = list(map(int,input().split()))
li = [0]
l = ['0']
ans = set()
for i in range(n):
  ans.add(str(li[-1] + lis[i]))
  l.append(str(li[-1] + lis[i]))
  li.append(li[-1] + lis[i])
cou = 0
for num in ans:
  co = l.count(str(num))
  co -= 1
  th = 1
  while co > 1:
    th *= co
    co -= 1
  cou += th
print(cou)