#include <bits/stdc++.h>
using namespace std;
template <typename T1, typename T2>
ostream& operator<<(ostream& O, pair<T1, T2> t) {
  return O << "(" << t.first << "," << t.second << ")";
}
template <typename T>
ostream& operator<<(ostream& O, vector<T> t) {
  for (int _ = 0; _ < (int)t.size(); ++_) O << t[_] << " ";
  return O;
}
int dp[509][509];
int n;
int fact[509];
int Cnk[509][509];
void rec(int c1, int c2) {
  if (dp[c1][c2] > 0) return;
  long long res = 0;
  if (c1 > 0) {
    rec(c1 - 1, c2);
    res += dp[c1 - 1][c2];
  }
  long long tmp = 0;
  if (c1 > 1) {
    rec(c1 - 2, c2);
    tmp = dp[c1 - 2][c2];
    for (int i = 1; i <= c2; ++i) {
      rec(c1 - 2, c2 - i);
      tmp += dp[c1 - 2][c2 - i] * Cnk[c2][i] * fact[i];
    }
  }
  res += tmp * (c1 - 1);
  tmp = 0;
  if (c2 > 0) {
    rec(c1, c2 - 1);
    tmp = dp[c1][c2 - 1];
  }
  res += tmp * c2;
  dp[c1][c2] = res;
}
int main() {
  ios_base::sync_with_stdio(0);
  fact[0] = 1;
  for (int i = 1; i < 509; ++i)
    fact[i] = (fact[i - 1] * 1LL * i) % (1000000007);
  memset(dp, 0, sizeof(dp));
  for (int i = 0; i < 509; ++i) dp[0][i] = fact[i];
  dp[1][0] = 1;
  memset(Cnk, 0, sizeof(Cnk));
  for (int i = 0; i < 509; ++i) Cnk[i][0] = 1;
  for (int i = 1; i < 509; ++i)
    for (int j = 1; j <= i; ++j)
      Cnk[i][j] = (Cnk[i - 1][j] + Cnk[i - 1][j - 1]) % (1000000007);
  cin >> n;
  int c1 = 0, c2 = 0, a;
  for (int i = 0; i < n; ++i) {
    cin >> a;
    if (a == 1)
      c1++;
    else
      c2++;
  }
  rec(c1, c2);
  cout << dp[c1][c2] << endl;
  return 0;
}
