var input = require("fs").readFileSync("/dev/stdin", "utf8");

var lines=input.split("\n");
var n=lines[0]|0;
var a=lines[1].split(" ");
var map=Object.create(null);
map[0]=0;
var sum=0;
var res=0;
for(var i=0;i<n;++i){
    sum+=a[i]|0;
    if(sum in map){
        res+=++map[sum];
    }else{
        map[sum]=0;
    }
}
console.log(res);
