from sys import stdin
from itertools import repeat
from collections import defaultdict
def main():
    n = int(stdin.readline())
    a = map(int, stdin.readline().split(), repeat(10, n))
    ans = s = 0
    d = defaultdict(int)
    d[0] = 1
    for x in a:
        s += x
        ans += d[s]
        d[s] += 1
    print ans
main()
