#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  long long int a[n];
  for (int i = 0; i < n; i++) cin >> a[i];
  long long int pre[n];
  pre[0] = a[0];
  for (int i = 1; i < n; i++) {
    pre[i] = pre[i - 1] + a[i];
  }
  set<long long int> s;
  long long int sum = 0;
  long long int ans = 0;
  for (int i = 0; i < n; i++) {
    sum += a[i];
    if (s.find(sum) != s.end() || sum == 0) {
      sum = a[i];
      s.clear();
      s.insert(sum);
      ans++;
    } else
      s.insert(sum);
  }
  cout << ans << "\n";
}
