#include <bits/stdc++.h>
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long n;
  cin >> n;
  long long a[n];
  for (long long i = 0; i < n; i++) {
    cin >> a[i];
  }
  unordered_map<long long, long long> cnt;
  long long sum = 0, ans = 0, last = -1;
  cnt[0] = -1;
  for (long long i = 0; i < n; i++) {
    sum += a[i];
    if (cnt.find(sum) != cnt.end() && cnt[sum] + 1 >= last) {
      ans++;
      last = i;
    }
    cnt[sum] = i;
  }
  cout << ans << "\n";
  return 0;
}
