#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, i, sum = 0, counter = 0, x;
  map<long long, int> mymap;
  cin >> n;
  mymap[0] = 1;
  for (i = 0; i < n; i++) {
    cin >> x;
    sum += x;
    if (mymap.count(sum) != 0) {
      mymap.clear();
      mymap[0] = 1;
      counter++;
      sum = x;
    }
    mymap[sum] = 1;
  }
  cout << counter;
}
