#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007;
void setIO(string name) {
  string in_f = name + ".in";
  string out_f = name + ".out";
  freopen(in_f.c_str(), "r", stdin);
  freopen(out_f.c_str(), "w", stdout);
}
int n0, k0;
long long dp[510][510];
long long mul[510];
void get_mul() {
  mul[0] = 1;
  for (int i = 1; i <= (500); ++i) mul[i] = mul[i - 1] * i % MOD;
}
void init() {
  cin >> n0;
  int t;
  k0 = 0;
  for (int i = 1; i <= (n0); ++i) {
    scanf("%d", &t);
    if (t == 2) ++k0;
  }
  get_mul();
}
void solve() {
  for (int k = (0); k <= (500); ++k) {
    dp[k][k] = mul[k], dp[k][k + 1] = mul[k + 1];
    for (int n = (k + 2); n <= (500); ++n) {
      dp[k][n] = (dp[k][n - 1] + (n - 1) * dp[k][n - 2]) % MOD;
      if (k) dp[k][n] = (dp[k][n] + k * dp[k - 1][n - 1]) % MOD;
    }
  }
  cout << dp[k0][n0] << endl;
}
int main() {
  init();
  solve();
  return 0;
}
