#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000007;
const long long inf = 1000000000000000000;
const long double PI = 3.1415926535897932384626;
const long double eps = 1e-12;
void __print(int32_t x) { cout << x; }
void __print(long long x) { cout << x; }
void __print(double x) { cout << x; }
void __print(long double x) { cout << x; }
void __print(float x) { cout << x; }
void __print(bool x) { cout << (x ? "true" : "false"); }
void __print(char x) { cout << '\'' << x << '\''; }
void __print(const char *x) { cout << '\"' << x << '\"'; }
void __print(const string &x) { cout << '\"' << x << '\"'; }
template <typename T, typename V>
void __print(const pair<T, V> &x) {
  cout << '{';
  __print(x.first);
  cout << ',';
  __print(x.second);
  cout << '}';
}
template <typename T>
void __print(const T &x) {
  long long f = 0;
  cout << '{';
  for (auto &i : x) cout << (f++ ? "," : ""), __print(i);
  cout << "}";
}
void _print() { cout << "]\n"; }
template <typename T, typename... V>
void _print(T t, V... v) {
  __print(t);
  if (sizeof...(v)) cout << ", ";
  _print(v...);
}
long long powerm(long long base, long long exp) {
  long long res = 1;
  base %= mod;
  while (exp > 0) {
    if (exp & 1) res = (res * base) % mod;
    base = (base * base) % mod;
    exp = exp >> 1;
  }
  return res;
}
long long power(long long base, long long exp) {
  long long res = 1;
  while (exp > 0) {
    if (exp & 1) res = res * base;
    base = base * base;
    exp = exp >> 1;
  }
  return res;
}
float powerNeg(float base, long long exp) {
  float temp;
  if (exp == 0) return 1;
  temp = powerNeg(base, exp / 2);
  if (exp % 2 == 0)
    return temp * temp;
  else {
    if (exp > 0)
      return base * temp * temp;
    else
      return (temp * temp) / base;
  }
}
long long modinv(long long exp) { return powerm(exp, mod - 2); }
const long long N = 2e6 + 5;
void solve() {
  long long i, j;
  long long n;
  cin >> n;
  vector<long long> a(n);
  for (i = 0; i <= n - 1; i++) cin >> a[i];
  long long cnt = 0;
  map<long long, long long> mp;
  mp[0]++;
  long long pre = 0;
  for (i = 0; i <= n - 1; i++) {
    pre += a[i];
    if (mp.count(pre)) {
      cnt++;
      mp.clear();
      mp[0]++;
      pre = a[i];
    }
    mp[pre]++;
  }
  cout << cnt << '\n';
}
int32_t main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long t, T = 1;
  for (t = 1; t <= T; t++) {
    solve();
  }
  return 0;
}
