#include <bits/stdc++.h>
using namespace std;
signed main() {
  long long n, ans = 0;
  cin >> n;
  vector<long long>(a)((n));
  vector<long long>(s)((n));
  cin >> a[0];
  s[0] = a[0];
  for (long long i = (1); i < (n); ++i) {
    cin >> a[i];
    s[i] = s[i - 1] + a[i];
  }
  sort(s.begin(), s.end());
  if (s[0] == 0) ans++;
  for (long long i = (1); i < (n); ++i) {
    if (s[i] == 0) {
      ans++;
    }
    if (s[i] == s[i - 1]) {
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}
