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]

nums = [0]*(n+1)
for j in range(n+1):
    nums[s[j]] += 1

res = 0
for v in nums:
    if v >= 1:
        res += v*(v-1)//2
        
print(res)