#include <bits/stdc++.h>
const double eps = 1e-9;
const double pi = acos(-1);
const int oo = 1000000000;
const int mod = 1000000007;
const double E = 2.7182818284590452353602874713527;
using namespace std;
int f[501][501], c[505][505], g[505], fac[505];
int main() {
  int n, x = 0, y = 0;
  cin >> n;
  for (int i = 0; i <= n; i++) {
    c[i][0] = 1;
    for (int j = 1; j <= i; j++)
      c[i][j] = (c[i - 1][j - 1] + c[i - 1][j]) % mod;
  }
  fac[0] = 1;
  for (int i = 1; i <= n; i++) {
    int a;
    fac[i] = 1LL * fac[i - 1] * i % mod;
    scanf("%d", &a);
    if (a == 1)
      x++;
    else
      y++;
  }
  g[0] = 1;
  for (int i = 1; i <= y; i++)
    for (int j = 0; j < i; j++)
      g[i] = (g[i] + 1LL * g[j] * fac[i - j - 1] % mod * c[i - 1][i - j - 1]) %
             mod;
  for (int i = 0; i <= y; i++) f[0][i] = g[i];
  for (int i = 1; i <= x; i++)
    for (int j = 0; j <= y; j++)
      for (int k = 0; k <= j; k++) {
        f[i][j] =
            (f[i][j] + 1LL * f[i - 1][k] * fac[j - k] % mod * c[j][j - k]) %
            mod;
        if (i > 1)
          f[i][j] = (f[i][j] + 1LL * f[i - 2][k] * fac[j - k + 1] % mod *
                                   c[j][j - k] % mod * (i - 1)) %
                    mod;
      }
  cout << f[x][y] << endl;
  return 0;
}
