from collections import Counter

from itertools import accumulate

eval(input());print((sum( (s*(s-1))//2  for s in list(Counter((i for i  in accumulate([0]+[int(i) for i in input().split()]))).values()))))

import collections,itertools;eval(input());print((sum( (s*(s-1))//2  for s in list(collections.Counter((i for i  in itertools.accumulate([0]+[int(i) for i in input().split()]))).values()))))
from collections import Counter
from itertools import accumulate

eval(input())
print(
    (
        sum(
            (s * (s - 1)) // 2
            for s in list(
                Counter(
                    (i for i in accumulate([0] + [int(i) for i in input().split()]))
                ).values()
            )
        )
    )
)

import collections, itertools

eval(input())
print(
    (
        sum(
            (s * (s - 1)) // 2
            for s in list(
                collections.Counter(
                    (
                        i
                        for i in itertools.accumulate(
                            [0] + [int(i) for i in input().split()]
                        )
                    )
                ).values()
            )
        )
    )
)

-from collections import Counter -from itertools import accumulate +import collections, itertools -                Counter( -                    (i for i in accumulate([0] + [int(i) for i in input().split()])) +                collections.Counter( +                    ( +                        i +                        for i in itertools.accumulate( +                            [0] + [int(i) for i in input().split()] +                        ) +                    )