#include <bits/stdc++.h>
using namespace std;
void solve() {
  int n, res = 0;
  long long pref[300500];
  cin >> n;
  for (int i = 1; i <= n; i++) {
    long long x;
    cin >> x;
    pref[i] = pref[i - 1] + x;
  }
  sort(pref + 1, pref + n + 1);
  for (int i = 1; i < n; i++) {
    if (pref[i] == pref[i + 1]) {
      res++;
    }
  }
  cout << res;
}
int main() {
  solve();
  return 0;
}
