#include <bits/stdc++.h>
using namespace std;
const int N = 200 * 1000 + 10, mod = 1e9 + 7;
long long ps[N], a[N];
map<long long, int> id;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  int prv = -1, ans = 0;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    ps[i + 1] = ps[i] + a[i];
    if (id[ps[i + 1]] || !ps[i + 1]) {
      if (prv <= id[ps[i + 1]]) {
        ans++;
        prv = i;
      }
    }
    id[ps[i + 1]] = i + 1;
  }
  cout << ans << '\n';
}
