function Main(input) {
	input = input.split("\n");
	var n = input[1].split(" ").map(Number);
	var arr = [];
  	var m = [0]
	for(var i=0;i<n.length;i++){
		m[i+1] = m[i]+n[i];
	}
	for(i=0;i<m.length;i++){
		if(arr[m[i]]){
			arr[m[i]]++;
		}else{
			arr[m[i]] = 1;
		}
	}
	var sum = 0;
 /* console.log(arr)
  console.log(m)*/
	Object.keys(arr).forEach(function(key){
		sum += arr[key]*(arr[key]-1)/2;
	});
	console.log(sum)
}Main(require("fs").readFileSync("/dev/stdin", "utf8").trim());