#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n;
  cin >> n;
  map<long long int, long long int> store;
  store[0]++;
  long long int val = 0;
  long long int ans = 0;
  for (long long int i = 0; i < n; i++) {
    long long int x;
    cin >> x;
    val += x;
    if (store[val] != 0) {
      map<long long int, long long int> temp;
      store = temp;
      store[0]++;
      val = x;
      store[val]++;
      ans++;
    } else
      store[val]++;
  }
  cout << ans;
}
