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