#include <bits/stdc++.h>
using namespace std;
void c_p_c() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
}
int32_t main() {
  c_p_c();
  long long n;
  cin >> n;
  vector<long long> a(n + 1);
  a[0] = 0;
  for (long long i = 1; i <= n; i++) {
    long long x;
    cin >> x;
    a[i] = x + a[i - 1];
  }
  map<long long, long long> m;
  vector<long long> dp(n + 1);
  dp[0] = 0;
  m[a[0]]++;
  for (long long i = 1; i <= n; i++) {
    m[a[i]]++;
    dp[i] = dp[i - 1];
    if (m[a[i]] == 2) {
      dp[i]++;
      m.erase(m.begin(), m.end());
      m[a[i]]++;
      m[a[i - 1]]++;
    }
  }
  for (long long i = n; i <= n; i++) {
    cout << dp[i] << endl;
  }
  return 0;
}
