#include <bits/stdc++.h>
using namespace std;
const int maxn = 110;
const int mod = 1e9 + 7;
int n, d[maxn], dp[maxn][maxn], cp[maxn][maxn], cnt[maxn][maxn];
int c[maxn][maxn], fac[maxn], fac2[maxn], inv2[maxn];
void buildc() {
  for (int i = 0; i <= n; i++) {
    c[i][i] = 1;
    c[i][0] = 1;
  }
  for (int i = 2; i <= n; i++) {
    for (int j = 1; j < i; j++) {
      c[i][j] = (c[i - 1][j] + c[i - 1][j - 1]) % mod;
    }
  }
}
void buildcnt() {
  cnt[0][0] = 1;
  cnt[0][1] = cnt[0][2] = 0;
  for (int i = 3; i <= n; i++) {
    for (int j = 2; j <= i - 1; j++) {
      int now =
          (((c[i - 1][j] * 1ll * fac2[j]) % mod) * 1ll * cnt[0][i - j - 1]) %
          mod;
      cnt[0][i] = (cnt[0][i] + now) % mod;
    }
  }
  for (int i = 2; i <= n; i += 2) {
    for (int j = 0; j <= n; j++) {
      int sum = 0;
      for (int z = 0; z <= j; z++) {
        int now =
            (((c[j][z] * 1ll * fac[z]) % mod) * 1ll * cnt[i - 2][j - z]) % mod;
        sum = (sum + now) % mod;
      }
      cnt[i][j] = ((i - 1) * 1ll * sum) % mod;
    }
  }
}
int poww(int a, int b) {
  if (b == 0) return 1;
  int x = poww(a, b / 2) % mod;
  if (b & 1)
    return (((x * 1ll * x) % mod) * 1ll * a) % mod;
  else
    return (x * 1ll * x) % mod;
}
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n;
  fac[0] = 1;
  fac2[2] = 1;
  inv2[0] = 1;
  int now = 1;
  for (int i = 1; i <= n; i++) {
    cin >> d[i];
    fac[i] = (fac[i - 1] * 1ll * i) % mod;
    if (i >= 3) fac2[i] = (fac2[i - 1] * 1ll * i) % mod;
    now = (now * 1ll * 2) % mod;
    inv2[i] = poww(now, mod - 2) % mod;
  }
  buildc();
  buildcnt();
  dp[1][1] = 1;
  cp[1][1] = 1;
  cp[d[1] + 1][d[1]] = 1;
  for (int j = 2; j <= n; j++) {
    for (int sz = 1; sz < j; sz++) {
      int c2 = 0, c3 = 0;
      for (int z = j - sz + 1; z <= j; z++) {
        if (d[z] == 2)
          c2++;
        else
          c3++;
      }
      int x0, x1, y0, y1, y2;
      for (x0 = 0; x0 <= c2; x0++) {
        for (y0 = 0; y0 <= c3; y0++) {
          for (y1 = 0; y1 <= c3 - y0; y1++) {
            x1 = c2 - x0;
            y2 = c3 - y0 - y1;
            int d1 = x1 + y1, d2 = y2;
            int p1 = x0 + y1, p2 = y0;
            int now = cp[j][sz];
            now = (now * 1ll *
                   ((((c[c2][x0] * 1ll * c[c3][y0]) % mod) * 1ll *
                     c[c3 - y0][y1]) %
                    mod)) %
                  mod;
            now = (now * 1ll * cnt[p1][p2]) % mod;
            dp[j][sz] = (dp[j][sz] + now) % mod;
            cp[j + d1 + (2 * d2)][d1 + (2 * d2)] =
                (cp[j + d1 + (2 * d2)][d1 + (2 * d2)] +
                 ((((now * 1ll * fac[(d1 + (2 * d2))]) % mod) * 1ll *
                   (inv2[d2] % mod)) %
                  mod)) %
                mod;
          }
        }
      }
    }
  }
  cout << cp[n][0] % mod;
  return 0;
}
