#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> arr(n);
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
  }
  long long ans = 0, sum = 0;
  unordered_set<long long> pref;
  pref.insert(0);
  for (int i = 0; i < n; i++) {
    sum += arr[i];
    if (pref.count(sum)) {
      ans++;
      pref.clear();
      pref.insert(0);
      sum = arr[i];
    }
    pref.insert(sum);
  }
  cout << ans << "\n";
  return 0;
}
