#include <bits/stdc++.h>
using namespace std;
const int N = 500;
int d[N], b[N];
vector<int> a[N];
long long w[N];
long long ans1;
int n;
int main() {
  srand(time(NULL));
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> b[i];
    d[i] = d[i - 1] + b[i];
  }
  for (int i = 1; i <= n; i++) {
    for (int j = i; j <= n; j++) {
      if (d[j] - d[i - 1] == 1) {
        a[i].push_back(j - i + 1);
      }
    }
  }
  w[0] = 1;
  for (int i = 1; i <= n; i++) {
    vector<pair<int, int> > ans;
    for (auto j : a[i]) {
      for (int t = i - 1; t >= i - 1; t--) {
        if (w[t] >= 1) {
          ans.push_back({t, j});
        }
      }
    }
    for (auto j : ans) {
      w[j.first + j.second] += w[j.first];
    }
  }
  cout << w[n];
  return 0;
}
