#include <bits/stdc++.h>
using namespace std;
const long double eps = 1e-9;
const int inf = (1 << 30) - 1;
const long long inf64 = ((long long)1 << 62) - 1;
const long double pi = 3.1415926535897932384626433832795;
template <class T>
T sqr(T x) {
  return x * x;
}
template <class T>
T abs(T x) {
  return x < 0 ? -x : x;
}
const long long mod = 1000000007;
long long dp[600][600];
void pre_calc() {
  dp[0][0] = 1;
  for (int i = 0; i < (int)(502); i++)
    for (int j = 0; j < (int)(502); j++) {
      if (i + j == 0) continue;
      dp[i][j] = 0;
      if (i == 0) {
        dp[i][j] = j * dp[i][j - 1] % mod;
        continue;
      }
      dp[i][j] += dp[i - 1][j];
      if (j > 0) dp[i][j] += j * dp[i][j - 1];
      if (i >= 2) {
        long long now = (i - 1);
        for (int k = 0; k <= j; k++) {
          dp[i][j] += dp[i - 2][j - k] * now % mod;
          now = now * (j - k) % mod;
        }
      }
      dp[i][j] %= mod;
    }
}
long long calc(int a, int b) { return dp[a][b]; }
int main() {
  pre_calc();
  int n, a, b;
  a = b = 0;
  cin >> n;
  for (int i = 0; i < (int)(n); i++) {
    int x;
    scanf("%d", &x);
    if (x == 1)
      a++;
    else
      b++;
  }
  cout << calc(a, b) << endl;
  return 0;
}
