#include <bits/stdc++.h>
using namespace std;
template <class _T>
inline _T sqr(const _T& x) {
  return x * x;
}
template <class _T>
inline string tostr(const _T& a) {
  ostringstream os("");
  os << a;
  return os.str();
}
const long double PI = 3.1415926535897932384626433832795;
const long double EPS = 1e-11;
const int MOD = 1000000007;
int n, k;
int d[512][512];
int c[512][512];
int f[512];
int d1[512];
int c2[512][512];
inline void add(int& a, int b) {
  a += b;
  a -= (a >= MOD) * MOD;
}
int main() {
  cout << setiosflags(ios::fixed) << setprecision(10);
  memset((c), 0, sizeof(c));
  memset((d1), 0, sizeof(d1));
  d1[0] = 1;
  f[0] = 1;
  for (int i = 0; i < (int)(501); i++) {
    f[i + 1] = f[i] * (signed long long)(i + 1) % MOD;
    c[i][0] = c[i][i] = 1;
    for (int j = (1); j <= (int)(i - 1); j++) {
      c[i][j] = c[i - 1][j - 1];
      add(c[i][j], c[i - 1][j]);
    }
    for (int j = 0; j < (int)(i + 1); j++) {
      c2[i][j] = c[i][j] * (signed long long)f[j] % MOD;
    }
    if (i >= 1) add(d1[i], d1[i - 1]);
    if (i >= 2) add(d1[i], d1[i - 2] * (signed long long)(i - 1) % MOD);
  }
  scanf("%d", &n);
  k = 0;
  for (int i = 0; i < (int)(n); i++) {
    int x;
    scanf("%d", &x);
    k += (x == 1);
  }
  int k1 = k;
  int k2 = n - k1;
  memset((d), 0, sizeof(d));
  d[0][0] = 1;
  for (int i1 = 0; i1 < (int)(k1 + 1); i1++) {
    for (int i2 = 0; i2 < (int)(k2 + 1); i2++) {
      int ma = min(2, k1);
      for (int j = (1); j <= (int)(i2); j++) {
        add(d[i1][i2],
            d[i1][i2 - j] * (signed long long)c2[i2 - 1][j - 1] % MOD);
      }
      for (int i = (1); i <= (int)(ma); i++) {
        for (int j = (1); j <= (int)(i2); j++) {
          add(d[i1][i2], d[i1 - i][i2 - j] * (signed long long)c[i1][i] % MOD *
                             (signed long long)c[i2 - 1][j - 1] % MOD *
                             f[i + j - 1] % MOD);
        }
      }
    }
  }
  int ans = 0;
  for (int i = 0; i < (int)(k1 + 1); i++) {
    add(ans, d[i][k2] * (signed long long)d1[k1 - i] % MOD *
                 (signed long long)c[k1][i] % MOD);
  }
  printf("%d\n", ans);
  return 0;
}
