#include <bits/stdc++.h>
using namespace std;
const long long int N = 3e5 + 5;
bool fun(pair<int, int> a, pair<int, int> b) {
  if (a.first == b.first)
    return a.second < b.second;
  else
    return a.first < b.first;
}
bool prime(long long int n) {
  if (n == 1) return false;
  for (long long int i = 2; i * i <= n; i++)
    if (n % i == 0) return false;
  return true;
}
long long int getSetBitsFromOneToN(long long int N) {
  long long int two = 2, ans = 0;
  long long int n = N;
  while (n) {
    ans += (N / two) * (two >> 1);
    if ((N & (two - 1)) > (two >> 1) - 1)
      ans += (N & (two - 1)) - (two >> 1) + 1;
    two <<= 1;
    n >>= 1;
  }
  return ans;
}
long long int power(long long int a, long long int b) {
  long long int res = 1;
  while (b > 0) {
    if (b & 1) res = res * a;
    a = a * a;
    b >>= 1;
  }
  return res;
}
long long int mod_pow(long long int a, long long int b, long long int m) {
  long long int res = 1;
  while (b) {
    if (b & 1) {
      res = (res * a) % m;
    }
    a = (a * a) % m;
    b >>= 1;
  }
  return res;
}
long long int gcd(long long int a, long long int b) {
  if (a == 0) return b;
  return gcd(b % a, a);
}
long long int lcm(long long int a, long long int b) {
  return (max(a, b) / gcd(a, b)) * min(a, b);
}
long long int mod_inverse(long long int a) {
  return mod_pow(a, 1000000007 - 2, 1000000007);
}
bool lodu(long long int n) {
  if (n == 0) return false;
  return (ceil(log2(n)) == floor(log2(n)));
}
long long int raju[N];
void SieveOfEratosthenes(long long int n) {
  bool prime[n + 1];
  long long int i = 0;
  memset(prime, true, sizeof(prime));
  for (long long int p = 2; p * p <= n; p++) {
    if (prime[p] == true) {
      for (long long int i = p * p; i <= n; i += p) prime[i] = false;
    }
  }
  for (long long int p = 2; p <= n; p++)
    if (prime[p]) raju[i++] = p;
}
void solve() {
  long long int n;
  cin >> n;
  long long int a[n + 1];
  for (long long int i = 1; i < n + 1; i++) {
    cin >> a[i];
  }
  multiset<long long int> s;
  long long int ans = 0;
  s.insert(0);
  long long int curr = 0;
  for (long long int i = 1; i < n + 1; i++) {
    curr += a[i];
    if (s.find(curr) != s.end()) {
      s.clear();
      ans++;
      curr = a[i];
      s.insert(curr);
      s.insert(0);
    } else {
      s.insert(curr);
    }
  }
  cout << ans << "\n";
}
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  long long int t = 1;
  while (t--) {
    solve();
  }
}
