#include <bits/stdc++.h>
using namespace std;
vector<pair<int, int> > findSubArrays(int arr[], int n) {
  map<int, vector<int> > map;
  vector<pair<int, int> > out;
  int sum = 0;
  for (int i = 0; i < n; i++) {
    sum += arr[i];
    if (sum == 0) out.push_back(make_pair(0, i));
    if (map.find(sum) != map.end()) {
      vector<int> vc = map[sum];
      vector<int>::iterator it;
      for (it = vc.begin(); it != vc.end(); it++)
        out.push_back(make_pair(*it + 1, i));
    }
    map[sum].push_back(i);
  }
  return out;
}
int a[200005];
int main() {
  int i, j, k, n, m, z = 0, c = 0, t, x, y, l, r, mid;
  cin >> n;
  for (i = 0; i < n; i++) cin >> a[i];
  vector<pair<int, int> > out = findSubArrays(a, n);
  cout << out.size() << endl;
  return 0;
}
