#include <bits/stdc++.h>
#pragma GCC optimize("O3")
using namespace std;
const long long INF = 0x3f3f3f3f;
const long long MAXN = 3e5;
long long pre, n, j, a, last = INF;
priority_queue<pair<long long, long long>, vector<pair<long long, long long>>,
               greater<pair<long long, long long>>>
    q;
map<long long, long long> m;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  m[0] = 1;
  for (long long i = 1; i <= n; i++) {
    cin >> a;
    pre += a;
    if (m[pre]) q.push({m[pre], i});
    m[pre] = i + 1;
  }
  while (q.size()) {
    while (q.size() && q.top().first < last) {
      last = min(q.top().second, last);
      q.pop();
    }
    last = INF;
    j++;
  }
  cout << j << '\n';
}
