package main

import (
	"fmt"
	"sort"
)

func Sum(n []int) int {
	res := 0
	for i := 0; i < len(n); i++ {
		res += n[i]
	}
	return res
}
func Conb(a, b int) int {
	top := 1
	bot := 1
	for i := 0; i < a-b; i++ {
		top *= (a - i)
		bot *= (b - i)
	}
	return top / bot
}
func main() {
	var N int
	fmt.Scan(&N)
	var A = make([]int, N)
	for i, _ := range A {
		fmt.Scan(&A[i])
	}

	ans := 0
	temp := 0
	var sum []int
	sum = append(sum, 0)
	for i := 0; i < N; i++ {
		temp += A[i]
		sum = append(sum, temp)
		A[i] = 0
	}
	sort.Ints(sum)

	for _, v := range sum {
		A[v]++
	}
	for _, v := range A {
		if v < 2 {
			continue
		}
		ans += Conb(v, 2)
	}
	fmt.Println(ans)
}