n = int(input())
a = list(map(int,input().split()))

s = []
p = 0

for i in range(n):
    p+=a[i]
    s.append(p)
s.append(0)

x = 0

s = collections.Counter(s)


for i in range(len(s)):
    x += (s[i][1]*(z[i][1]-1))//2
print(x)
