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

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