#include <bits/stdc++.h>
using namespace std;
signed main() {
  long long n;
  cin >> n;
  vector<long long> v(n);
  for (long long i = 0; i < n; i++) cin >> v[i];
  set<long long> s;
  s.insert(0);
  long long ans = 0;
  long long sum = 0;
  for (long long i = 0; i < n; i++) {
    sum += v[i];
    if (s.count(sum)) {
      ans++;
      s.clear();
      s.insert(0);
      i--;
      sum = 0;
    } else
      s.insert(sum);
  }
  cout << ans << endl;
  return 0;
}
