#include <bits/stdc++.h>
using namespace std;
long long int convertstringtoint(string a) {
  long long int ans = 0;
  for (long long int i = 0; i < a.size(); i++) {
    ans = (ans * 10) + a[i] - '0';
    ans = ans;
  }
  return ans;
}
void solve() {
  long long int n;
  cin >> n;
  vector<long long int> v(n, 0);
  for (long long int i = 0; i < n; i++) {
    cin >> v[i];
  }
  long long int s = 0;
  long long int ans = 0;
  map<long long int, long long int> m;
  m[0] = 1;
  for (long long int i = 0; i < n; ++i) {
    s += v[i];
    if (m.count((s))) {
      ans++;
      m.clear();
      m[0] = 1;
      m[v[i]] = 1;
      s = v[i];
    }
    m[s]++;
  }
  cout << ans;
}
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long int t;
  t = 1;
  while (t--) solve();
}
