#include <bits/stdc++.h>
using namespace std;
int a[2000005];
map<long long, bool> q;
int main() {
  long long n, sum = 0, ans = 0;
  cin >> n;
  q[0] = 1;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    sum += a[i];
    if (q[sum]) {
      ans++;
      q.clear();
      sum = a[i];
      q[0] = 1;
    }
    q[sum] = 1;
  }
  cout << ans;
  return 0;
}
