#include <bits/stdc++.h>
using namespace std;
const long long N = 2e5 + 5;
long long n, a[N], s = 0;
map<long long, long long> mp;
void in() {
  cin >> n;
  for (long long i = 1; i <= n; i++) cin >> a[i];
  mp[0] = 1;
}
void process() {
  long long res = 0;
  for (long long i = 1; i <= n; i++) {
    s += a[i];
    if (mp[s]) {
      res++;
      mp.clear();
      mp[a[i]] = 1, mp[0] = 1;
      s = a[i];
    } else
      mp[s] = 1;
  }
  cout << res << '\n';
}
int main() {
  if (fopen("trash.inp", "r"))
    freopen("trash.inp", "r", stdin), freopen("trash.out", "w", stdout);
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  in();
  process();
}
