#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n;
  cin >> n;
  vector<long long> a(n);
  for (long long i = 0; i < n; i++) {
    cin >> a.at(i);
  }
  vector<long long> s(n);
  s.at(0) = a.at(0);
  for (long long i = 1; i < n; i++) {
    s.at(i) = s.at(i - 1) + a.at(i);
  }
  long long cnt = 0;
  sort(s.begin(), s.end());
  long long i = 0;
  while (s.at(i) == 0) {
    i++;
    cnt++;
  }
  i = 0;
  vector<long long> t(n);
  long long k;
  t.at(0) = 1;
  for (k = 1; k < n; k++) {
    t.at(k) = 0;
  }
  k = 0;
  for (long long j = 0; j < n - 1; j++) {
    if (s.at(j) == s.at(j + 1)) {
      t.at(k)++;
    } else {
      k++;
      t.at(k)++;
    }
  }
  for (long long m = 0; m < n; m++) {
    cnt += t.at(m) * (t.at(m) - 1) / 2;
  }
  cout << cnt << endl;
}
