#include <bits/stdc++.h>
#pragma GCC optimize(2)
using namespace std;
inline int read() {
  int x = 0;
  int f = 0;
  char ch = 0;
  while (!isdigit(ch)) {
    f |= (ch == '-') ? 1 : 0;
    ch = getchar();
  }
  while (isdigit(ch)) {
    x = (x << 3) + (x << 1) + (ch ^ 48);
    ch = getchar();
  }
  return f ? -x : x;
}
const int maxn = 2e5 + 10;
int n, aa[maxn];
long long sum[maxn];
map<long long, int> mp;
int nxt[maxn];
int main() {
  n = read();
  for (register int i = 1; i <= n; ++i) aa[i] = read();
  sum[0] = 0;
  for (register int i = 1; i <= n; ++i) sum[i] = sum[i - 1] + aa[i];
  for (register int i = n; i >= 0; --i) {
    nxt[i] = mp[sum[i]];
    mp[sum[i]] = i;
  }
  int ans = 0;
  int mx = 1e9;
  for (register int i = 0; i <= n; ++i) {
    if (mx == i) {
      ++ans;
      if (nxt[i - 1])
        mx = nxt[i - 1];
      else
        mx = 1e9;
    }
    if (nxt[i]) mx = min(mx, nxt[i]);
  }
  printf("%d\n", ans);
}
