#include <bits/stdc++.h>
const double PI = 3.141592653589793238460;
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n;
  cin >> n;
  vector<int> v(n);
  for (int i = 0; i < n; i++) {
    cin >> v[i];
  }
  unordered_map<long long int, long long int> m;
  long long int rs = 0;
  long long int count = 0;
  m[0] = 1;
  for (int i = 0; i < n; i++) {
    rs += v[i];
    if (m.find(rs) != m.end()) {
      count++;
      m.clear();
      m[0] += 1;
      rs = v[i];
    }
    m[rs] += 1;
  }
  cout << count << '\n';
}
