package main

import (
	"fmt"
	"sort"
)

func main() {
	var n, a int
	fmt.Scan(&n)
	s := []int{0}

	for i := 0; i < n; i++ {
		fmt.Scan(&a)
		s = append(s, s[len(s)-1]+a)
	}
	sort.Ints(s)
	ans := 0
	cnt := 0
	for i := 0; i < len(s); i++ {
		if s[i-1] == s[i] {
			cnt++
		} else {
			cnt = 0
		}
		ans += cnt
	}
	fmt.Println(ans)
}
