#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int l, i = 0, a[n];
  while (cin >> l) {
    a[i] = l;
    i++;
  }
  int cnt = 0;
  int tmp = 0;
  vector<int> vc;
  vector<int> uvc;
  vc.push_back(0);
  uvc.push_back(0);
  for (int j = 0; j < n; j++) {
    tmp += a[j];
    vc.push_back(tmp);
    auto itr = find(uvc.begin(), uvc.end(), tmp);
    if (itr == uvc.end()) {
      uvc.push_back(tmp);
    }
  }
  for (int k = 0; k < (int)uvc.size(); ++k) {
    int t = count(vc.begin(), vc.end(), uvc[k]);
    cnt += int(t * (t - 1) / 2);
  }
  cout << cnt << endl;
  return 0;
}
