#include <bits/stdc++.h>
using namespace std;
const int MAXN = 555;
const long long MOD = 1000000007;
long long fact[MAXN], choose[MAXN][MAXN], dp[MAXN][MAXN];
int main() {
  int n, m, a;
  scanf("%d", &n);
  m = 0;
  for (int i = 0; i < n; ++i) {
    scanf("%d", &a);
    if (a == 1) {
      ++m;
    }
  }
  for (int i = 0; i <= n; ++i) {
    fact[i] = i == 0 ? 1 : fact[i - 1] * i % MOD;
    choose[i][0] = 1;
    for (int j = 1; j <= i; ++j) {
      choose[i][j] = (choose[i - 1][j - 1] + choose[i - 1][j]) % MOD;
    }
  }
  dp[n][m] = 1;
  for (int i = n; i > 0; --i) {
    for (int j = m; j > 0; --j) {
      for (int k = i - j + 1; k >= 1; --k) {
        dp[i - k][j - 1] =
            (dp[i - k][j - 1] +
             fact[k - 1] * choose[i - j][k - 1] % MOD * dp[i][j]) %
            MOD;
      }
      if (j < 2) {
        continue;
      }
      for (int k = i - j + 2; k >= 2; --k) {
        dp[i - k][j - 2] =
            (dp[i - k][j - 2] + fact[k - 1] * (j - 1) % MOD *
                                    choose[i - j][k - 2] % MOD * dp[i][j]) %
            MOD;
      }
    }
    for (int k = i; k > 0; --k) {
      dp[i - k][0] =
          (dp[i - k][0] + fact[k - 1] * choose[i - 1][k - 1] % MOD * dp[i][0]) %
          MOD;
    }
  }
  printf("%d\n", (int)dp[0][0]);
  return 0;
}
