#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vs = vector<string>;
using msi = map<string, int>;
using mii = map<int, int>;
using psi = pair<string, int>;
using pii = pair<int, int>;
using vlai = valarray<int>;
std::ostream &operator<<(std::ostream &out, const vector<int> &tgt) {
  string s;
  for (int i = 0; i < tgt.size(); i++) {
    s += (to_string(tgt[i]) + ((i != tgt.size() - 1) ? " " : ""));
  }
  out << s;
  return out;
}
int main() {
  int n, in, sum = 0, ans = 0;
  map<int, int> m;
  cin >> n;
  m[0] = 1;
  for (int i = 0; i < n; i++) {
    cin >> in;
    sum += in;
    if (m[sum])
      m[sum]++;
    else
      m[sum] = 1;
  }
  for (auto itr = m.begin(); itr != m.end(); itr++) {
    ans += max(0, itr->second - 1);
  }
  cout << ans << endl;
}
