package main

import (
	"io"
	"os"

	"fmt"
)

func Solve(in io.Reader, out io.Writer) {
	var n int
	fmt.Fscan(in, &n)

	a := make([]int64, n)

	for i := 0; i < n; i++ {
		fmt.Fscan(in, &a[i])
	}

	var cnt int
	for i := 0; i < n; i++ {
		sum := a[i]
		for j := i + 1; j < n; j++ {
			sum += a[j]
			if sum == 0 {
				cnt++
			}
		}

	}

	fmt.Fprintln(out, cnt)
}

func main() {
	Solve(os.Stdin, os.Stdout)
}
