#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  long long a[n];
  vector<long long> pref(n + 1, 0);
  for (int i = 0; i < n; i++) cin >> a[i];
  for (int i = 0; i < n; i++) {
    pref[i + 1] = pref[i] + a[i];
  }
  map<long long, int> m;
  m[0] = 0;
  long long ans = 0;
  int prev = -1;
  for (int i = 1; i <= n; i++) {
    if (m.find(pref[i]) != m.end()) {
      if (m[pref[i]] >= prev - 1) {
        ans++;
        prev = i;
      }
    }
    m[pref[i]] = i;
  }
  cout << ans << endl;
}
