package main

import "fmt"

const debug = true

func main() {
	var N int
	fmt.Scan(&N)
	nums := scanNums(N)

	var cnt int
	for b := 0; b < N; b++ {
		for e := N; e > b; e-- {
			if sum(nums[b:e]) == 0 {
				cnt++
			}
		}
	}
	fmt.Println(cnt)
}

func scanNums(length int) (nums []int) {
	var num int
	for i := 0; i < length; i++ {
		fmt.Scan(&num)
		nums = append(nums, num)
	}
	return
}

func sum(nums []int) (sum int) {
	for i := 0; i < len(nums); i++ {
		sum += nums[i]
	}
	return
}
