package main

import "fmt"

const debug = true

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

	var sumsMax int
	sumsFromZero = append(sumsFromZero, nums[0])
	for i := 1; i < N; i++ {
		sumsFromZero = append(sumsFromZero, sumsFromZero[i-1]+nums[i])
		if sumsMax < sumsFromZero[i] {
			sumsMax = sumsFromZero[i]
		}
	}

	sumsFromZero = append([]int{0}, sumsFromZero...)

	sameNums := map[int]int{}
	var sameNumsKeyMoreThanTwo []int
	for i := 0; i <= sumsMax; i++ {
		for j := 0; j <= N; j++ {
			if sumsFromZero[j] == i {
				sameNums[i]++
			}
			if sameNums[i] >= 2 {
				sameNumsKeyMoreThanTwo = append(sameNumsKeyMoreThanTwo, i)
			}
		}
	}

	sum := 0
	for _, v := range sameNums {
		sum += combination(v, 2)
	}

	fmt.Println(sum)
}

func combination(n, r int) (cmb int) {
	a := 1
	b := 1
	for i := 0; i < r; i++ {
		a *= n - i
		b *= r - i
	}
	return (a / b)
}

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