#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7, N = 51;
int d[N];
long long f[N][2 * N][N][N];
int main() {
  int n;
  scanf("%d", &n);
  for (int i = (0), i_end = (n); i < i_end; ++i) scanf("%d", d + i);
  if (d[1] == 2)
    f[1][d[0] - 1][1][0] = d[0] * d[1];
  else
    f[1][d[0] - 1][0][1] = d[0] * d[1];
  for (int i = (1), i_end = (n - 1); i < i_end; ++i)
    for (int j = (0), j_end = (2 * n + 1); j < j_end; ++j)
      for (int k = (0), k_end = (n + 1); k < k_end; ++k)
        for (int l = (0), l_end = (n + 1); l < l_end; ++l) {
          long long now = f[i][j][k][l];
          if (now == 0) continue;
          if (j > 0) {
            if (d[i + 1] == 2) {
              long long tmp = j * 2 * now;
              (f[i + 1][j - 1][k + 1][l] += tmp) %= MOD;
              if (k > 0) (f[i + 1][j - 1][k - 1][l] += tmp * k) %= MOD;
              if (l > 0) (f[i + 1][j - 1][k + 1][l - 1] += tmp * l * 2) %= MOD;
            } else {
              long long tmp = j * 3 * now;
              (f[i + 1][j - 1][k][l + 1] += tmp) %= MOD;
              if (k > 0) {
                (f[i + 1][j - 1][k][l] += 2 * tmp * k) %= MOD;
                if (k > 1)
                  (f[i + 1][j - 1][k - 2][l] += tmp * k * (k - 1)) %= MOD;
              }
              if (l > 0) {
                (f[i + 1][j - 1][k + 2][l - 1] += tmp * l * 4) %= MOD;
                if (k > 0)
                  (f[i + 1][j - 1][k][l - 1] += tmp * l * 4 * k) %= MOD;
                if (l > 1)
                  (f[i + 1][j - 1][k + 2][l - 2] += tmp * l * (l - 1) * 4) %=
                      MOD;
              }
            }
          } else {
            int p = k + 2 * l;
            if (d[i + 1] == 2) {
              long long tmp = p * 2 * now;
              (f[i + 1][p - 1][1][0] += tmp) %= MOD;
            } else {
              long long tmp = p * 3 * now;
              (f[i + 1][p - 1][0][1] += tmp) %= MOD;
            }
          }
        }
  long long ans = f[n - 1][0][0][0];
  for (int i = (0), i_end = (n); i < i_end; ++i)
    (ans *= (d[i] == 2 ? 500000004 : 166666668)) %= MOD;
  printf(
      "%"
      "I64"
      "d\n",
      ans);
  return 0;
}
