#include <bits/stdc++.h>
using namespace std;
int main() {
  long N, sum = 0;
  cin >> N;
  vector<vector<long>> a;
  a.resize(N);
  a.at(0).resize(N);
  for (long i = 0; i < N; i++) {
    cin >> a.at(0).at(i);
  }
  if (N >= 2) {
    a.at(1).resize(N - 1);
    for (long i = 0; i < N - 1; i++) {
      a.at(1).at(i) = a.at(0).at(i) + a.at(0).at(i + 1);
    }
  }
  for (long i = 2; i < N; i++) {
    a.at(i).resize(N - i);
    for (long j = 0; j < N - i; j++) {
      a.at(i).at(j) =
          a.at(i - 1).at(j) + a.at(i - 1).at(j + 1) - a.at(i - 2).at(j + 1);
    }
  }
  for (long i = 0; i < a.size(); i++)
    for (long j = 0; j < a.at(i).size(); j++)
      if (a.at(i).at(j) == 0) sum++;
  cout << sum << endl;
  return 0;
}
