#include <bits/stdc++.h>
using namespace std;
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long n;
  cin >> n;
  vector<long long> a(n);
  for (long long i = 0; i < n; i++) cin >> a[i];
  set<long long> s;
  s.insert(0);
  long long cur = 0;
  long long ans = 0;
  for (long long i = 0; i < n; i++) {
    cur += a[i];
    if (s.find(cur) != s.end()) {
      ans++;
      s.clear();
      cur = a[i];
      s.insert(0);
    }
    s.insert(cur);
  }
  cout << ans << '\n';
}
