#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  long long *v = new long long[n + 1];
  v[0] = 0;
  for (int i = 1; i < n + 1; i++) {
    cin >> v[i];
    v[i] += v[i - 1];
    ;
  }
  long long cnt = 0;
  map<long long, int> comb;
  for (int i = 0; i < n + 1; i++) {
    comb[v[i]] += 1;
  }
  for (auto x : comb) {
    if (x.second > 1) {
      cnt += (x.second * (x.second - 1)) / 2;
    }
  }
  cout << cnt;
  delete (v);
  return 0;
}
