#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = (0), i_end_ = (n); i < i_end_; i++) {
    cin >> a[i];
  }
  int ans = 0;
  int suma = 0;
  for (int i = (2), i_end_ = (n + 1); i < i_end_; i++) {
    suma = 0;
    for (int j = (0), j_end_ = (i); j < j_end_; j++) {
      suma += a[j];
    }
    if (suma == 0) {
      ans += 1;
    }
    for (int j = (0), j_end_ = (n - i); j < j_end_; j++) {
      suma = suma - a[j] + a[j + i];
      if (suma == 0) {
        ans += 1;
      }
    }
  }
  cout << ans << "\n";
  return 0;
}
