#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n;
  cin >> n;
  long long a[n];
  set<long long> v;
  v.insert(0);
  for (long long i = 0; i < n; i++) {
    cin >> a[i];
  }
  long long pref = 0;
  long long cntr = 0;
  for (long long i = 0; i < n; i++) {
    pref += a[i];
    if (v.find(pref) != v.end()) {
      v.clear();
      v.insert(0);
      pref = a[i];
      cntr++;
    }
    v.insert(pref);
  }
  cout << cntr << endl;
}
