#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 10;
int n, a[N];
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  long long sum = 0, ans = 0;
  map<long long, int> cnt;
  cnt[0]++;
  for (int i = 1; i <= n; i++) {
    sum = sum + a[i];
    if (cnt[sum] > 0) {
      ans++;
      cnt.clear();
      cnt[0]++;
      sum = a[i];
    }
    cnt[sum]++;
  }
  cout << ans;
}
