#include <bits/stdc++.h>
using namespace std;
const int maxn = 200010;
int n, idx[maxn], cur[maxn], len[maxn];
long long a[maxn];
vector<int> vec[maxn];
vector<long long> b;
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%lld", &a[i]);
  b.push_back(0);
  for (int i = 1; i <= n; i++) {
    a[i] += a[i - 1];
    b.push_back(a[i]);
  }
  sort(b.begin(), b.end());
  b.erase(unique(b.begin(), b.end()), b.end());
  idx[0] = lower_bound(b.begin(), b.end(), 0) - b.begin() + 1;
  for (int i = 1; i <= n; i++) {
    int id = lower_bound(b.begin(), b.end(), a[i]) - b.begin() + 1;
    idx[i] = id;
    len[id]++;
    vec[id].push_back(i);
  }
  int ans = 0;
  int i = 1, r = 2e9 + 10;
  while (i <= n) {
    if (cur[idx[i - 1]] >= len[idx[i - 1]]) {
      cur[idx[i]]++;
      i++;
      continue;
    }
    if (r <= i) {
      ans++;
      r = 2e9 + 10;
    }
    r = min(r, vec[idx[i - 1]][cur[idx[i - 1]]]);
    cur[idx[i]]++;
    i++;
  }
  if (r != 2e9 + 10) ans++;
  printf("%d\n", ans);
}
