#include <bits/stdc++.h>
using namespace std;
int n, c1, c2;
int dp[505][505], fact[1000005], inv[1000005];
int po(int a, int b) {
  int c = 1, d = a;
  while (b) {
    if (b & 1) c = 1LL * c * d % 1000000007;
    d = 1LL * d * d % 1000000007;
    b >>= 1;
  }
  return c;
}
int ncr(int N, int R) {
  if (R > N || R < 0) return 0;
  int ret = fact[N];
  ret = 1LL * ret * inv[R] % 1000000007;
  ret = 1LL * ret * inv[N - R] % 1000000007;
  return ret;
}
int f(int a, int b) {
  if (a == 0) return dp[a][b] = fact[b];
  if (dp[a][b] != -1) return dp[a][b];
  dp[a][b] = 0;
  for (int i = (0); i <= (b); i++)
    dp[a][b] =
        (dp[a][b] + 1LL * ncr(b, i) * fact[i] % 1000000007 * f(a - 1, b - i)) %
        1000000007;
  if (a > 1) {
    for (int i = (0); i <= (b); i++)
      dp[a][b] = (dp[a][b] + 1LL * ncr(b, i) * (a - 1) % 1000000007 *
                                 fact[i + 1] % 1000000007 * f(a - 2, b - i)) %
                 1000000007;
  }
  return dp[a][b];
}
void solve() {
  memset(dp, -1, sizeof(dp));
  printf("%d\n", f(c1, c2));
}
int main() {
  fact[0] = 1;
  for (int i = (1); i <= (1000000); i++)
    fact[i] = 1LL * fact[i - 1] * i % 1000000007;
  for (int i = (0); i <= (1000000); i++) inv[i] = po(fact[i], 1000000007 - 2);
  scanf("%d", &n);
  for (int i = (1); i <= (n); i++) {
    int x;
    scanf("%d", &x);
    if (x == 1)
      c1++;
    else
      c2++;
  }
  solve();
  return 0;
}
