#include <bits/stdc++.h>
using namespace std;
const double eps = 1e-8;
const int NINF = 0xc0c0c0c0;
const int INF = 0x3f3f3f3f;
const long long mod = 1e9 + 7;
const long long N = 1e6 + 5;
long long n, a[N], pre[N];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cin >> n;
  unordered_map<long long, int> M;
  long long ans = 0;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    pre[i] = pre[i - 1] + a[i];
    if (M.count(pre[i]) || pre[i] == 0) {
      ans++, M.clear();
      pre[i] = a[i];
    }
    M[pre[i]] = i;
  }
  cout << ans << '\n';
  return 0;
}
