// inputに入力データ全体が入る
function Main(input) {
	input = input.split("\n");
	var n = input[0]
	var a = input[1].split(" ");
	var ret = 0;
	for(var i = 0;i<n;i++){
		ret+= sum(i,a)
	}
	
	console.log(ret);
	
}
var ans = [];

function sum(start,args){
	var count = 0;
	var sum = 0;
	
	if(ans[start]){
		return ans[start];
	}
	
	var memo = [];
	for(var i = 0;i<args.length;i++){
		sum+=Number(args[i+start]);
		if(sum == 0){
			count++;
			if(i+start+1<args.length){
				memo.push(i+start+1);
			}
		}
	}
	
	if(memo){
		for(var i = 0;i<memo.length;i++)
		ans[memo.shift()]  = count-1-i;
	}
	return count;
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));
