#include <bits/stdc++.h>
using namespace std;
int n, a[100];
long long dp[101];
int main() {
  cin >> n;
  for (int i = 0; i < n; ++i) cin >> a[i];
  dp[0] = 1;
  for (int i = 0; i < n; ++i)
    if (dp[i]) {
      int nu = 0;
      for (int j = i; j < n && nu < 2; ++j) {
        if (a[j]) nu++;
        if (nu == 1) dp[j + 1] += dp[i];
      }
    }
  cout << dp[n] << endl;
}
