#include <bits/stdc++.h>
using namespace std;
struct st {
  long long var, cnt;
  st(long long _var) : var(_var), cnt(1) {}
};
int main(void) {
  int n;
  vector<long long> v, v128;
  cin >> n;
  v.reserve(n);
  for (int i = 0; i < n; ++i) {
    long long tmp;
    cin >> tmp;
    v.push_back(tmp);
  }
  int cnt = 0;
  vector<st> vs;
  for (int i = n - 1; i >= 0; --i) {
    bool found = false;
    for (int j = 0; j < vs.size(); ++j) {
      if (vs[j].var == 0) {
        found = true;
        ++vs[j].cnt;
      }
      vs[j].var += v[i];
      if (vs[j].var == 0) cnt += vs[j].cnt;
    }
    if (not found) {
      vs.push_back(st(v[i]));
      if (v[i] == 0) ++cnt;
    }
  }
  cout << cnt << endl;
  return 0;
}
