import collections
n = int(input())
a = [int(i) for i in input().split()]
s = [sum(a[:i]) for i in range(1,n+1)]
c = collections.Counter(s)
d = [i*(i-1)//2 for i in c.values() if i>1]
print(sum(d)+c[0])
