#include <bits/stdc++.h>
using namespace std;
int n, pos = 0, ans = 0;
long long a[2000001], s = 0;
map<long long, long long> mp;
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    s += a[i];
    if (((!s && !mp[s]) || mp[s]) && mp[s] >= pos) {
      ans++;
      pos = i - 1;
    }
    mp[s] = i;
  }
  cout << ans;
  return 0;
}
