#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long int n;
  cin >> n;
  vector<long long int> pref(n + 1, 0);
  for (long long int i = 0; i < n; i++) {
    long long int a;
    cin >> a;
    pref[i + 1] = pref[i] + a;
  }
  long long int i = 0, j = 0, ans = 0;
  set<long long int> s;
  s.insert(0);
  while (i < n) {
    while (j < n && s.find(pref[j + 1] - pref[i]) == s.end()) {
      j++;
      s.insert(pref[j] - pref[i]);
    }
    if (j < n) ans++;
    s.clear();
    s.insert(0);
    i = j;
  }
  cout << ans << endl;
  return 0;
}
