#include <bits/stdc++.h>
using namespace std;
const int N = 3e5;
long long n, ans, r;
long long a[N];
map<long long, long long> mp;
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> a[i], a[i] += a[i - 1];
  mp[0] = 0;
  for (int i = 1; i <= n; i++)
    if (mp.find(a[i]) == mp.end())
      mp[a[i]] = i;
    else {
      if (mp[a[i]] >= r) ans++, r = i - 1;
      mp[a[i]] = i;
    }
  cout << ans << endl;
  ans = 0;
  r = 0;
  mp.clear();
}
