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 = 0
	var cnt = 0

	while(s(cnt) == 0){
		ans += 1
		cnt += 1
	}

	var tp1 = s(0)
	cnt = 1

	for(i<-1 until n){
		if(tp1 == s(i)){
			cnt += 1
		}else{
			tp1 = s(i)
			if(cnt >= 2){
				ans += combi(cnt, 2)
			}
			cnt = 1
		}
	}

	if(cnt >= 2){
		ans += combi(cnt, 2)
	}

	println(ans)

	def combi(n: Int, r: Int): Int = {
		if(n==r) return 1
		else if(r == 0) return 1
		else if(r == 1) return n
		else return combi(n-1,r-1) + combi(n-1,r)
	}
}