#include <bits/stdc++.h>
using namespace std;
using cd = complex<double>;
const double pi = acos(-1);
vector<long long> ft(1, 1LL);
void solve() {
  long long n, sum = 0, ans = 0;
  map<long long, long long> m;
  cin >> n;
  m[0] = 1;
  for (long long i = 0; i < n; i++) {
    long long a;
    cin >> a;
    sum += a;
    if (m[sum] != 0) {
      ans++;
      sum = a;
      m.clear();
      m[0] = 1;
    }
    m[sum] = 1;
  }
  cout << ans << '\n';
}
signed main() {
  cin.sync_with_stdio(0);
  cin.tie(0);
  cin.exceptions(cin.failbit);
  long long t = 1;
  while (t--) {
    solve();
  }
}
