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