# coding: utf-8
# Your code here!

from itertools import accumulate
from collections import deque

N = int(input())
a = deque(list(map(int, input().split())))
tmp_a = []
tmp_n = 0
ctr = 0

for i in range(N):
    tmp = list(accumulate(list(a)))
    #print(tmp)
    ctr += tmp.count(0)
    tmp_n = a.popleft()
print(ctr)
