#include <bits/stdc++.h>
using namespace std;
void solve(int arr[], long long n) {
  unordered_map<long long, int> M;
  vector<pair<int, int> > out;
  long long sum = 0;
  for (int i = 0; i < n; i++) {
    sum += arr[i];
    if (sum == 0) out.push_back(make_pair(0, i));
    if (M.find(sum) != M.end()) {
      out.push_back(make_pair(M[sum] + 1, i));
    }
    M[sum] = i;
  }
  int last = 0, res = 0;
  for (int i = 0; i < int(out.size()); i++) {
    swap(out[i].first, out[i].second);
  }
  sort(out.begin(), out.end());
  for (int i = 0; i < int(out.size()); i++) {
    if (out[i].second >= last) {
      res++;
      last = out[i].first;
    }
  }
  cout << res;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  int arr[n];
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
  }
  solve(arr, n);
  return 0;
}
