#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000007;
const unsigned gen_seed =
    std::chrono::system_clock::now().time_since_epoch().count();
std::mt19937_64 gen(gen_seed);
const int A = 500;
long long d[A + 1][A + 1];
long long fac[A + 1];
long long ifac[A + 1];
long long cfac[A + 1][A + 1];
long long cfac2[A + 1][A + 1];
long long gcd(long long a, long long b, long long& x, long long& y) {
  if (a == 0) {
    x = 0;
    y = 1;
    return b;
  }
  long long x1, y1;
  long long d = gcd(b % a, a, x1, y1);
  x = y1 - (b / a) * x1;
  y = x1;
  return d;
}
long long invmod(long long a, long long modulo) {
  long long x, y;
  gcd(a, modulo, x, y);
  return (x % modulo + modulo) % modulo;
}
int main() {
  fac[0] = 1;
  for (long long i = 1; i <= A; i++) fac[i] = (fac[i - 1] * i) % mod;
  for (int i = 0; i < A + 1; i++) ifac[i] = invmod(fac[i], mod);
  d[0][0] = 1;
  for (int i = 0; i < A + 1; i++)
    for (int j = 0; j < i + 1; j++) cfac[i][j] = fac[i] * ifac[i - j] % mod;
  for (int i = 0; i < A + 1; i++)
    for (int j = 0; j < i + 1; j++) cfac2[i][j] = cfac[i][j] * (j + 1) % mod;
  for (int b = 0; b < A + 1; b++)
    for (int a = 0; a < A + 1; a++) {
      if (a == 0) {
        if (b > 0) d[0][b] = (d[0][b - 1] * b) % mod;
        continue;
      }
      for (int tb = 0; tb < b + 1; tb++) {
        d[a][b] += d[a - 1][b - tb] * cfac[b][tb] % mod;
      }
      if (a > 1) {
        long long cand = 0;
        for (int tb = 0; tb < b + 1; tb++) {
          cand += d[a - 2][b - tb] * cfac2[b][tb] % mod;
        }
        d[a][b] += cand * (a - 1);
      }
      d[a][b] %= mod;
    }
  int n;
  scanf("%d", &n);
  int a = 0;
  int b = 0;
  for (int i = 0; i < n; i++) {
    int x;
    scanf("%d", &x);
    if (x == 1)
      a++;
    else
      b++;
  }
  cout << d[a][b];
}
