#include <bits/stdc++.h>
using namespace std;
long long mod = 1e9 + 7;
long long huge = (1ll << 60);
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long t;
  long long n, m, u, v, k, x, y, ct, q, cnt, z, ff;
  t = 1;
  while (t--) {
    cin >> n;
    long long ar[n];
    set<long long> s;
    s.insert(0ll);
    u = 0ll;
    long long ans = 0ll;
    for (int i = 0; i < n; i++) cin >> ar[i];
    for (int i = 0; i < n; i++) {
      u += ar[i];
      if (s.find(u) != s.end()) {
        ans++;
        s.clear();
        s.insert(0ll);
        u = ar[i];
      }
      s.insert(u);
    }
    cout << ans << "\n";
  }
}
