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 cnt = 1
	var tp = s(0)

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

	if(tp == 0){
		ans += cnt + combi(cnt, 2)
	}else{
		ans += combi(cnt, 2)
	}

	println(ans)


	def combi(n: Long, r: Long): Long = {
		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)
	}


}