#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<long long> v;
  long long m = 0;
  long long count = 0;
  v.push_back(0);
  for (int i = 0; i < n; i++) {
    long long k;
    cin >> k;
    if (k == 0) count++;
    m += k;
    v.push_back(m);
  }
  sort(v.begin(), v.end());
  long long prev;
  long long cnt = 0;
  for (int i = 0; i < n + 1; i++) {
    if (i == 0) {
      prev = v[i];
      cnt = 1;
    } else {
      if (prev == v[i])
        cnt++;
      else {
        long long u = cnt * (cnt - 1);
        u /= 2;
        count += u;
        prev = v[i];
        cnt = 1;
      }
    }
  }
  long long u = cnt * (cnt - 1);
  u /= 2;
  count += u;
  cout << count << endl;
  return 0;
}
