from itertools import accumulate

def main():
    N = int(input())
    A = tuple(map(int, input().split()))

    a = [0] + list(accumulate(A))
    cnt = 0
    fin = set()
    for i in a:
        n = a.count(i) - 1
        if i not in fin:
            cnt += n * (n + 1) // 2
            fin.add(i)
    print(cnt)

main()
