#include <bits/stdc++.h>
using namespace std;
template <typename T>
void out(std::initializer_list<T> text) {
  for (const auto& value : text) std::cout << value << " ";
  cout << endl;
}
template <typename FwdIter>
void print(FwdIter b, FwdIter e) {
  while (b != e) {
    cout << *b << " ";
    b++;
  }
  cout << "\n";
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ;
  long long i, n, left = 0, c = 0, curr = 0;
  cin >> n;
  long long arr[n];
  for (long long i = 0; i < n; i++) {
    cin >> arr[i];
  };
  ;
  unordered_map<long long, long long> umap;
  umap[0] = 0;
  for (long long i = 0; i < n; i++) {
    curr = curr + arr[i];
    if (umap.count(curr) && umap[curr] >= left) {
      left = i;
      c++;
    }
    umap[curr] = i + 1;
  }
  cout << c << endl;
  return 0;
}
