'use strict';
console.log(function(args){
  const tmp = args.trim().split('\n');
  const N = tmp[0]|0;
  const A = tmp[1].split(' ').map(v=>parseInt(v,10));
  const s = [0];
  const map = new Map([[0,1]]);
  for ( let i = 0; i < N; i++ ) {
    s.push( A[i] + s[i] );
    map.set(s[i+1], (map.get(s[i+1])|0) + 1);
  }
  let count = 0;
  for ( let v of map.values() ) {
    count += v * ( v - 1 ) / 2;
  }
  return count.toString();
}(require('fs').readFileSync('/dev/stdin', 'utf8')));
