#include <bits/stdc++.h>
using namespace std;
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long n;
  cin >> n;
  long long a[n];
  for (long long i = 0; i < n; ++i) cin >> a[i];
  set<long long> s;
  long long sum = 0, ans = 0;
  map<long long, long long> m;
  m[0] = -1;
  for (long long i = 0; i < n; ++i) {
    sum += a[i];
    if (m.count(sum)) {
      auto it = s.upper_bound(m[sum] + 1);
      if (it == s.end()) ++ans, s.insert(i);
    }
    m[sum] = i;
  }
  cout << ans;
}
