#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long n, a[200009], sum = 0, ans = 0;
  set<long long int> hold;
  cin >> n;
  hold.insert(0);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    sum += a[i];
    if (hold.find(sum) != hold.end()) {
      ans++;
      hold.clear();
      sum = a[i];
      hold.insert(0);
      hold.insert(sum);
    } else
      hold.insert(sum);
  }
  cout << ans;
  return 0;
}
