#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, k = 0, cur = 0;
  cin >> n;
  vector<int> a(n);
  map<long long, long long> m;
  m[0]++;
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
    cur += a[i];
    if (m[cur] > 0) {
      k++;
      cur = a[i];
      m.clear();
      m[0]++;
    }
    m[cur]++;
  }
  cout << k << endl;
  return 0;
}
