#include <bits/stdc++.h>
using namespace std;
void think() {
  long long n;
  cin >> n;
  vector<long long> a(n);
  for (long long i = 0; i < n; i++) {
    cin >> a[i];
  }
  long long ans = 0;
  unordered_map<long long, long long> mp;
  mp[a[0]]++;
  for (long long i = 1; i < n; i++) {
    long long x = a[i];
    a[i] += a[i - 1];
    if (mp.find(a[i]) != mp.end() || a[i] == 0) {
      ans++;
      mp.clear();
      a[i] = x;
      mp[a[i]]++;
    } else {
      mp[a[i]]++;
    }
  }
  cout << ans << "\n";
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ;
  long long testcase = 1;
  while (testcase--) {
    think();
  }
  return 0;
}
