# A

N = int(input())
A = list(map(int, input().split()))

Acum = [0] + A
ls = set()
ls.add(0)
for i in range(1, N+1):
    Acum[i] += Acum[i-1]
    ls.add(Acum[i])

lst = []
for n in ls:
    num = Acum.count(n)
    if num > 1:
        lst.append(num * (num - 1) / 2)

if lst:
    print(int(sum(lst)))
else:
    print(0)