package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"strconv"
)

var (
	readString func() string
	stdout     *bufio.Writer
)

func init() {
	readString = newReadString(os.Stdin)
	stdout = bufio.NewWriter(os.Stdout)
}

func newReadString(ior io.Reader) func() string {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	return func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 0, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readIntSlice(n int) []int {
	b := make([]int, n)
	for i := 0; i < n; i++ {
		b[i] = readInt()
	}
	return b
}

func readLengthAndSlice() (int, []int) {
	n := readInt()
	return n, readIntSlice(n)
}

func printf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(stdout, f, args...)
}

func println(args ...interface{}) (int, error) {
	return fmt.Fprintln(stdout, args...)
}

func eprintln(args ...interface{}) (int, error) {
	return fmt.Fprintln(os.Stderr, args...)
}

func eprintf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(os.Stderr, f, args...)
}

// readString() string
// readInt() int
// readIntSlice(n int) []int
// readLengthAndSlice() []int

// -----------------------------------------------------------------------------

func main() {
	defer stdout.Flush()
	n := readInt()
	a := make([]int, n)
	for i := range a {
		a[i] = readInt()
	}
	sum := cumulativeSum(a)
	var ans int64
	for i := 1; i <= n; i++ {
		for j := 0; i+j <= n; j++ {
			if sum(j, i+j) == 0 {
				ans++
			}
		}
	}
	println(ans)
}

// -----------------------------------------------------------------------------

// cumulativeSum returns a function func(i, j int) int64 which returns
// the sum of a[i:j]
func cumulativeSum(a []int) func(int, int) int64 {
	n := len(a)
	b := make([]int64, n+1)
	for i := 0; i < n; i++ {
		b[i+1] = int64(a[i]) + b[i]
	}
	return func(i, j int) int64 {
		return b[j] - b[i]
	}
}

// cumulativeSum2D returns a function func(i0, j0, i1, j1 int) int64
// which returns the sum of a[i0][j0:j1], a[i0+1][j0:j1], ...,
// a[i1-1][j0:j1]
func cumulativeSum2D(a [][]int) func(int, int, int, int) int64 {
	n := len(a)
	m := len(a[0])
	b := make([][]int64, n+1)
	for i := 0; i <= n; i++ {
		b[i] = make([]int64, m+1)
	}

	for i := 1; i <= n; i++ {
		for j := 1; j <= m; j++ {
			b[i][j] = int64(a[i-1][j-1]) + b[i][j-1]
		}
	}
	for j := 1; j <= m; j++ {
		for i := 1; i <= n; i++ {
			b[i][j] += b[i-1][j]
		}
	}

	return func(i0, j0, i1, j1 int) int64 {
		return b[i1][j1] - b[i0][j1] - b[i1][j0] + b[i0][j0]
	}
}
