#include <bits/stdc++.h>
#include <math.h>
#define rep(i, n) for(int i = 0; i < n; ++i)
using namespace std;

int main() {
  int64_t n, s = 0, tmp = 0;
  cin >> n;
  vector<int64_t> a(n);
  rep(i, n){
    if(i == 0) cin >> v[i];
    else{
      int b;
      cin >> b;
      a[i] = a[i-1] + b;
    }
  }
  sort(a.begin(), a.end());
  rep(i, n-1){
    if(a[i] == a[i+1]){
      ++tmp;
      s += tmp;
    }
    else tmp = 0;
  }
  cout << s << endl;
  return 0;
}