N = int(input())
a = list(map(int,input().split()))
s = [0]*(len(a)+1)
for i in range(len(a)):
    s[i+1] = s[i] + a[i]
s.sort()
n = 0
for x in set(s):
    l = s.count(x)
    n += l*(l-1)/2
print(int(n))