#include <bits/stdc++.h>
using namespace std;
void testcase() {
  long long n;
  cin >> n;
  map<long long, long long> mp;
  long long *a = new long long[n];
  long long ans = 0;
  mp[0] = 1;
  long long s = 0;
  for (long long i = 0; i < n; i++) {
    cin >> a[i];
    s += a[i];
    if (mp.count(s) != 0) {
      map<long long, long long> mp2;
      mp2[0] = 1;
      mp2[a[i]] = 1;
      mp = mp2;
      ans++;
      s = a[i];
    } else
      mp[s] = 1;
  }
  cout << ans << "\n";
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long t = 1, k = 1;
  do {
    testcase();
    k++;
    t--;
  } while (t > 0);
  return 0;
}
