#include <bits/stdc++.h>
const unsigned P = 1e9 + 7;
inline unsigned long long moc(unsigned long long a) {
  return a < P ? a : a - P;
}
inline unsigned long long mod(unsigned long long a) {
  return a < P ? a : a % P;
}
inline void upd(unsigned long long& a, unsigned long long b) { a = mod(a + b); }
inline unsigned long long qow(unsigned long long a, unsigned k) {
  static unsigned long long w;
  for (w = 1; k; a = mod(a * a), k >>= 1)
    if (k & 1) w = mod(w * a);
  return w;
}
inline unsigned long long inv(unsigned long long a) { return qow(a, P - 2); }
int n, o, i, j, k, l, d, s;
unsigned long long e, g[3 + 1], f[2][50 * 2 + 1][50 + 1][50 + 1];
int main() {
  scanf("%d", &n);
  g[0] = 1;
  for (i = 1; i <= 3; ++i) g[i] = mod(g[i - 1] * inv(i));
  scanf("%d", &d);
  s = d, f[o = 0][d][0][0] = g[d];
  for (i = 1; i < n; ++i) {
    o ^= 1;
    for (j = 0; j <= s; ++j)
      for (k = 0; k <= i; ++k)
        for (l = 0; l <= i - k; ++l) f[o][j][k][l] = 0;
    scanf("%d", &d);
    switch (--d) {
      case 1:
        for (j = 1; j <= s; ++j)
          for (k = 0; k <= i; ++k)
            for (l = 0; l <= i - k; ++l)
              if (f[o ^ 1][j][k][l]) {
                e = mod(f[o ^ 1][j][k][l] * j);
                upd(f[o][j - 1][k + 1][l], e);
                if (k >= 1) upd(f[o][j - 1][k - 1][l], e * k);
                if (l >= 1) upd(f[o][j - 1][k + 1][l - 1], e * l);
              }
        break;
      case 2:
        for (j = 1; j <= s; ++j)
          for (k = 0; k <= i; ++k)
            for (l = 0; l <= i - k; ++l)
              if (f[o ^ 1][j][k][l]) {
                e = mod(f[o ^ 1][j][k][l] * j);
                upd(f[o][j - 1][k][l + 1], e);
                if (k >= 1) upd(f[o][j - 1][k][l], e * k);
                if (l >= 1) upd(f[o][j - 1][k + 2][l - 1], e * l);
                if (k >= 1 && l >= 1) upd(f[o][j - 1][k][l - 1], e * k * l);
                if (k >= 2) upd(f[o][j - 1][k - 2][l], e * (k * (k - 1) / 2));
                if (l >= 2)
                  upd(f[o][j - 1][k + 2][l - 2], e * (l * (l - 1) / 2));
              }
        break;
    }
    for (k = 0; k <= i + 1; ++k)
      for (l = !k; l <= i - k + 1; ++l)
        if (f[o][0][k][l])
          upd(f[o][k + l * 2][0][0], f[o][0][k][l] * qow(g[2], l));
    s += d;
  }
  printf(
      "%llu"
      "\n",
      f[o][0][0][0]);
  return 0;
}
