#include <bits/stdc++.h>
using namespace std;
const int N = 305, P = 1e9 + 7;
int n;
int deg[N], f[N][N][N], g[N][N][N];
void File() {
  freopen("graph.in", "r", stdin);
  freopen("graph.out", "w", stdout);
}
int main() {
  int totc[3] = {0, 0, 0};
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &deg[i]), totc[deg[i] - 1]++;
  g[0][0][0] = 1;
  totc[1] = totc[2] = n;
  for (int i = 0; i <= totc[2]; i++)
    for (int j = 0; j <= totc[1]; j++)
      for (int k = (!i && !j); k <= n && k <= 2 * i + j; k++) {
        int sg = 0;
        if (i) {
          if (i > 2)
            sg = (sg + 1ll * g[i - 3][j + 2][k] * (i - 1) * (i - 2) / 2) % P;
          if (j > 1) sg = (sg + 1ll * g[i - 1][j - 2][k] * j * (j - 1) / 2) % P;
          if (k > 1) sg = (sg + 1ll * g[i - 1][j][k - 2] * k * (k - 1) / 2) % P;
          if (j && k) sg = (sg + 1ll * g[i - 1][j - 1][k - 1] * j * k) % P;
          if (i > 1 && k)
            sg = (sg + 1ll * g[i - 2][j + 1][k - 1] * (i - 1) * k) % P;
          if (i > 1 && j) sg = (sg + 1ll * g[i - 2][j][k] * (i - 1) * j) % P;
        } else {
          if (k) sg = (sg + 1ll * g[0][j - 1][k - 1] * k) % P;
          if (j > 1) sg = (sg + 1ll * g[0][j - 2][k] * (j - 1)) % P;
        }
        g[i][j][k] = sg;
      }
  int c[3] = {0, 0, 0};
  for (int i = 2; i <= deg[1] + 1; i++) c[deg[i] - 1]++;
  f[deg[1] + 1][c[2]][c[1]] = 1;
  for (int i = deg[1] + 1; i < n; i++)
    for (int j = 0; j <= totc[2]; j++)
      for (int k = 0; k <= totc[1]; k++) {
        if (!f[i][j][k]) continue;
        c[1] = c[2] = 0;
        for (int r = i + 1; r <= n; r++) {
          c[deg[r] - 1]++;
          f[r][c[2]][c[1]] =
              (f[r][c[2]][c[1]] + 1ll * f[i][j][k] * g[j][k][r - i]) % P;
        }
      }
  int ans = 0;
  for (int i = 0; i <= totc[2]; i++)
    for (int j = 0; j <= totc[1]; j++)
      ans = (ans + 1ll * f[n][i][j] * g[i][j][0]) % P;
  printf("%d\n", ans);
  return 0;
}
