#include <bits/stdc++.h>
#pragma GCC optimize(2)
#pragma GCC optimize(3)
#pragma GCC optimize("Ofast")
using namespace std;
long long read() {
  long long s = 0, w = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') w = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9')
    s = (s << 3) + (s << 1) + (ch ^ 48), ch = getchar();
  return s * w;
}
long long s[200010], a[200010], n, top, cnt;
std::map<long long, long long> mp;
struct Edge {
  long long x, y;
} q[200010];
bool cmp(Edge x, Edge y) { return x.x == y.x ? x.y < y.y : x.x < y.x; }
signed main() {
  n = read();
  for (long long i = 1; i <= n; i++) s[i] = s[i - 1] + (a[i] = read());
  mp[0] = -1;
  for (long long i = 1; i <= n; i++) {
    if (mp[s[i]]) q[++top] = (Edge){(mp[s[i]] == -1 ? 0 : mp[s[i]]) + 2, i};
    mp[s[i]] = i;
  }
  if (!top) return printf("0\n"), 0;
  long long nw = q[1].y;
  ++cnt;
  for (long long i = 2; i <= top; i++)
    if (q[i].x > nw) nw = q[i].y, ++cnt;
  printf("%lld\n", cnt);
  return 0;
}
