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

def comb(n, r):
    def fact(n):
        if n <= 1:
            return 1
        else:
            return n*fact(n-1)
    return fact(n)//(fact(n-r)*fact(r))

s = [0]*(n+1)
for i in range(n):
    s[i+1] = s[i] + a[i]

ans = 0
for i in range(len(s)):
    if s.count(i) > 1:
        ans += comb(s.count(i), 2)
print(ans)