#include <bits/stdc++.h>
using namespace std;
long long int sum() { return 0; }
template <typename T, typename... Args>
T sum(T a, Args... args) {
  return a + sum(args...);
}
void solve() {
  long long int n;
  cin >> n;
  long long int a[n];
  for (__typeof(n) i = (0) - ((0) > (n)); i != (n) - ((0) > (n));
       i += 1 - 2 * ((0) > (n)))
    cin >> a[i];
  unordered_set<long long int> m;
  long long int psum = a[0];
  long long int ans = 0;
  m.insert(psum);
  for (long long int i = 1; i < n; i++) {
    psum += a[i];
    if (psum == 0) {
      ans++;
      psum = a[i];
      m.clear();
    }
    if (m.find(psum) != m.end()) {
      ans++;
      psum = a[i];
      m.clear();
    }
    m.insert(psum);
  }
  cout << ans << "\n";
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long int t = 1;
  while (t--) {
    solve();
  }
}
