#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; ++i) cin >> a[i];
  int used[200001];
  for (int i = 0; i < 200001; ++i) used[i] = -1;
  int ans = 0;
  for (int i = 0; i < n - 1; ++i) {
    int sum = a[i];
    for (int j = i + 1; j < n; ++j) {
      sum += a[j];
      if (sum == 0) {
        ans += 1;
        used[j] = i;
      }
    }
  }
  int index = n - 1;
  while (used[index] != -1) index = used[index];
  if (index == 0)
    cout << ans << endl;
  else
    cout << 0 << endl;
  return 0;
}
