object Main extends App {
	val n = scala.io.StdIn.readInt
	val a = scala.io.StdIn.readLine.split(" ").map(_.toLong)

	var s = new Array[Long](n)

	s(0) = a(0)

	for(i<-1 until n){
		s(i) = s(i-1) + a(i)
	}

	s = s.sorted

	var ans = 0L
	var tp = s(0)
	var count = 1

	for(i<-1 until n){
		if(tp != s(i)){
			if(count >= 2){
				ans += conbi(count, 2)
			}
			if(tp == 0L){
				ans += count
			}
			tp = s(i)
			count = 1
		}else{
			count += 1
		}
	}

	if(count >= 2){
				ans += conbi(count, 2)
			}
			if(tp == 0L){
				ans += count
			}

	println(ans)

	def conbi(n: Long, r: Long): Long = {
		if(n < r) return 0
		else if(n == r) return 1
		else if(r == 0) return 1
		else if(r == 1) return n
		else return conbi(n-1, r-1) + conbi(n-1, r)
	}
}