#include <bits/stdc++.h>
#pragma GCC optimize("O3")
using namespace std;
const long long N = 1e5 + 13;
const long long mod = 1e9 + 7;
const long long rx[] = {-1, +1, 0, 0};
const long long ry[] = {0, 0, -1, +1};
const long double eps = 0.00001;
const long long inf = 1e18;
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long n;
  cin >> n;
  vector<long long> a(n);
  for (long long i = 0; i < n; ++i) {
    cin >> a[i];
  }
  set<long long> st;
  long long cur = 0;
  st.insert(cur);
  long long ans = 0;
  for (long long i = 0; i < n; ++i) {
    cur += a[i];
    if (st.count(cur)) {
      st.clear();
      st.insert(0);
      cur = a[i];
      ++ans;
    }
    st.insert(cur);
  }
  cout << ans;
  return 0;
}
