def solve(n, a):
    b = [0] * n
    v = 0
    ans = 0
    for i in range(n):
        v += a[i]
        b[i] = v
        if v == 0:
            ans += 1
    D = {}
    for v in b:
        if not v in D:
            D[v] = 0
        D[v] += 1
    for k, v in D.items():
        if v > 1:
            ans += v * (v-1) / 2
    return ans

assert solve(6, [1,3,-4,2,2,-2]) == 3
assert solve(7, [1,-1,1,-1,1,-1,1]) == 12
assert solve(5, [1,-2,3,-4,5]) == 0
n = input()
a = map(int, raw_input().split())
print solve(n, a)