#include <bits/stdc++.h>
using namespace std;
bool mycompare(pair<long long, long long> &a, pair<long long, long long> &b) {
  if (a.second != b.second) return a.second < b.second;
  return a.first < b.first;
}
long long solve(vector<long long> &a, long long n) {
  map<long long, long long> m;
  vector<pair<long long, long long>> parr;
  long long cumsum = 0;
  m[cumsum] = -1;
  for (long long i = 0; i < n; i++) {
    cumsum += a[i];
    if (m.find(cumsum) != m.end()) {
      pair<long long, long long> temp = {m[cumsum] + 1, i};
      parr.push_back(temp);
    }
    m[cumsum] = i;
  }
  sort(parr.begin(), parr.end(), mycompare);
  long long ans = 0;
  for (long long i = 0; i < parr.size(); i++) {
    long long j = i + 1;
    long long endp = parr[i].second;
    while (j < parr.size() && endp > parr[j].first) {
      j++;
      endp = min(endp, parr[j].second);
    }
    i = j - 1;
    ans++;
  }
  return ans;
}
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];
  cout << solve(a, n) << '\n';
}
