#include <bits/stdc++.h>
using namespace std;
template <typename T>
inline void read(T& x) {
  static char b, f;
  b = getchar();
  f = 1, x = 0;
  for (; !isdigit(b); b = getchar())
    if (b == '-') f = -1;
  for (; isdigit(b); b = getchar()) x = (x << 1) + (x << 3) + b - '0';
  x *= f;
}
template <typename T, typename... Args>
inline void read(T& x, Args&... args) {
  read(x);
  read(args...);
}
long long qpow(long long q, long long n, long long mod) {
  long long ans = 1 % mod;
  while (n) {
    if (n & 1) ans = ans * q % mod;
    q = q * q % mod;
    n >>= 1;
  }
  return ans;
}
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
long long lcm(long long a, long long b) { return a * b / gcd(a, b); }
const long double eps = 1e-6;
const long double pi = acos(-1);
const long long lnf = 0x3f3f3f3f3f3f3f3f;
const int inf = 0x3f3f3f3f;
const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, 1, 0, -1};
const char ds[] = "DRUL";
const int mod = 7 + 1e9;
const int N = 3 + 2e5;
int n, a[N];
map<long long, int> m;
int main() {
  ios::sync_with_stdio(false);
  cin >> n;
  for (int i = 1; i <= n; ++i) cin >> a[i];
  long long pre = 0;
  int ans = 0;
  for (int i = 1; i <= n; ++i) {
    pre += a[i];
    if (!pre || m[pre]) {
      pre = a[i];
      ++ans;
      m.clear();
      m[pre] = 1;
    } else
      m[pre] = 1;
  }
  cout << ans << '\n';
  return 0;
}
