package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)

	aSum := make([]int, n+1)
	for i := 0; i < n; i++ {
		var a int
		fmt.Scan(&a)

		aSum[i+1] = a + aSum[i]
	}
	store := make(map[int]int, n)

	cnt := 0
	for i := 0; i < n+1; i++ {
		store[aSum[i]]++
		if store[aSum[i]] == 2 {
			store[aSum[i]] = 0
			cnt++
		}

	}
	fmt.Println(cnt)

}
