import collections
n = int(input())
a = list(map(int,input().split()))
b = [0]
s = 0
for x in a:
  s += x
  b.append(s)
c = collections.Counter(b)
k = 0
for x in c.values():
  k += x*(x-1)//2
print(k)