#include <bits/stdc++.h>
using namespace std;
void solve() {
  int n;
  cin >> n;
  long long int arr[n];
  long long int sum = 0;
  set<long long int> s;
  s.insert(0);
  int count = 0;
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
    sum += arr[i];
    if (s.count(sum)) {
      count++;
      s.clear();
      s.insert(0);
      s.insert(arr[i]);
      sum = arr[i];
    } else
      s.insert(sum);
  }
  cout << count << "\n";
}
int main() {
  solve();
  return 0;
}
