#include <bits/stdc++.h>
using namespace std;
template <typename A1>
void prn(A1&& arg) {
  cout << arg << '\n';
}
template <typename A1, typename... A>
void prn(A1&& arg, A&&... args) {
  cout << arg << ' ';
  prn(args...);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long n;
  cin >> n;
  long long a[n];
  for (long long i = 0; i < n; i++) cin >> a[i];
  map<long long, long long> mp;
  mp[0]++;
  long long s = 0, ans = 0, prev = 0;
  for (long long i = 0; i < n; i++) {
    s += a[i];
    if (mp.find(s) != mp.end()) {
      ans++;
      s += 1000000000000000;
      mp[s - a[i]]++;
    }
    mp[s]++;
  }
  prn(ans);
}
