#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
const long long inf = 922337203685477;
const long long nax = 2e5 + 5;
long long n;
long long a[nax], bit[nax];
map<long long, long long> mp;
void upd(long long x, long long y) {
  for (long long i = x; i < nax; i += i & -i) {
    bit[i] += y;
  }
}
long long que(long long x) {
  long long ret = 0;
  for (long long i = x; i > 0; i -= i & -i) {
    ret += bit[i];
  }
  return ret;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  cin >> n;
  for (long long i = 1; i <= n; i++) {
    cin >> a[i];
  }
  mp[0] = 1;
  long long sum = 0, ans = 0;
  for (long long i = 1; i <= n; i++) {
    sum += a[i];
    if (!mp.count(sum)) {
      mp[sum] = i;
    } else {
      long long ret = que(i) - que(mp[sum]);
      if (ret == 0) {
        ans++;
        upd(i - 1, 1);
      }
      mp[sum] = i;
    }
  }
  cout << ans << '\n';
}
