function Main(inp){
	inp=inp.split("\n");
	var n=+inp[0];
	var a=inp[1].split(" ");
	var sums={0:1};
	var sum=0;
	for(var i=0;i<n;i++){
		sum+=+a[i];
		sums[sum]=sums[sum]?sums[sum]+1:1;
	}
	var ans=0;
	for(var i in sums){
		ans+=sums[i]*(sums[i]-1)/2;
	}
	console.log(ans)
}


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