#include <bits/stdc++.h>
using namespace std;
inline long long read() {
  char ch = getchar();
  long long s = 0, w = 1;
  while (ch < '0' || ch > '9') {
    if (ch == '-') w = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    s = s * 10 + ch - '0';
    ch = getchar();
  }
  return s * w;
}
int g[310][310][310], f[310][310], fac[310], inv2;
int n, d1, d2, mod = 1e9 + 7, d[310];
int sum1[310], sum2[310], inv[310];
inline int Z(int x) { return x >= mod ? x - mod : x; }
inline int ksm(int a, int b) {
  int ans = 1;
  while (b) {
    if (b & 1) ans = 1LL * ans * a % mod;
    b >>= 1;
    a = 1LL * a * a % mod;
  }
  return ans;
}
inline int QS(int l, int r, int opt) {
  if (opt == 0) return sum1[r] - sum1[l - 1];
  if (opt == 1) return sum2[r] - sum2[l - 1];
  return 0;
}
inline int C(int n, int m) {
  if (n < m) return 0;
  return 1LL * fac[n] * inv[m] % mod * inv[n - m] % mod;
}
int main() {
  n = read();
  inv2 = ksm(2, mod - 2);
  fac[0] = 1;
  for (register int i = 1; i <= 300; i++) fac[i] = 1LL * fac[i - 1] * i % mod;
  for (register int i = 0; i <= 300; i++) inv[i] = ksm(fac[i], mod - 2);
  for (register int i = 1; i <= n; i++) {
    d[i] = read();
    if (d[i] == 2)
      d1++;
    else
      d2++;
  }
  for (register int i = 0; i <= 300; i++) {
    for (register int j = 0; j <= 300; j++) {
      for (register int k = 0; k <= 300; k++) {
        if (!i && !j && !k) {
          g[i][j][k] = 1;
          continue;
        } else if (!i && !j) {
          for (register int l = 3; l <= k; l++) {
            g[i][j][k] =
                Z(g[i][j][k] + 1LL * g[i][j][k - l] * fac[l - 1] % mod * inv2 %
                                   mod * C(k - 1, l - 1) % mod);
          }
        } else if (!i) {
          if (j >= 2)
            g[i][j][k] = Z(g[i][j][k] + 1LL * g[i][j - 2][k] * (j - 1) % mod);
          if (k >= 1)
            g[i][j][k] = Z(g[i][j][k] + 1LL * g[i][j][k - 1] * k % mod);
        } else {
          if (k >= 1)
            g[i][j][k] = Z(g[i][j][k] + 1LL * g[i - 1][j + 1][k - 1] * k % mod);
          if (j >= 1)
            g[i][j][k] = Z(g[i][j][k] + 1LL * g[i - 1][j - 1][k] * j % mod);
        }
      }
    }
  }
  for (register int i = 1; i <= n; i++) sum1[i] = sum1[i - 1] + (d[i] == 2);
  for (register int i = 1; i <= n; i++) sum2[i] = sum2[i - 1] + (d[i] == 3);
  f[d[1] + 1][d[1]] = 1;
  for (register int i = 1; i <= n; i++) {
    for (register int j = 1; j <= i; j++) {
      for (register int k = 1; k <= i - j; k++) {
        int p = i - j;
        f[i][j] = Z(f[i][j] +
                    1LL * f[p][k] *
                        g[j][QS(p - k + 1, p, 0)][QS(p - k + 1, p, 1)] % mod);
      }
    }
  }
  int ans = 0;
  for (register int i = 1; i <= n; i++) {
    int p = n - i + 1;
    ans = Z(ans + 1LL * f[n][i] * g[0][QS(p, n, 0)][QS(p, n, 1)] % mod);
  }
  printf("%d\n", ans);
  return 0;
}
