#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  set<int64_t> observed;
  int64_t prefixSum = 0;
  int64_t resets = 0;
  observed.insert(0);
  for (int i = 0; i < n; ++i) {
    int cur;
    cin >> cur;
    prefixSum += cur;
    if (observed.count(prefixSum)) {
      prefixSum = cur;
      resets++;
      observed.clear();
      observed.insert(0);
    }
    observed.insert(prefixSum);
  }
  cout << resets << endl;
  return 0;
}
