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);
	
}

function sum(start,args){
	var count = 0;
	var sum = 0;
	
	for(var i = 0;i<args.length;i++){
		sum+=Number(args[i+start]);
		if(sum == 0){
			count++;
		}
	}
	return count;
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
