#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const int mod = 1e9 + 7, N = 555;
int n, v[N];
int choose[N][N];
int dp[N][N];
long long fat[N];
void prep() {
  choose[0][0] = 1;
  for (int i = 1; i < N; i++) {
    choose[i][0] = 1;
    for (int j = 1; j < i; j++)
      choose[i][j] = (choose[i - 1][j] + choose[i - 1][j - 1]) % mod;
    choose[i][i] = 1;
  }
  fat[0] = fat[1] = 1;
  for (int i = 2; i < N; i++) fat[i] = 1LL * fat[i - 1] * i % mod;
}
int f(int c1, int c2) {
  if (!c1) return fat[c2];
  int &ret = dp[c1][c2];
  if (ret != -1) return ret;
  ret = 0;
  for (int j = 0; j <= c2; j++) {
    if (c1 > 0)
      ret =
          (ret + 1LL * f(c1 - 1, c2 - j) * choose[c2][j] % mod * fat[j] % mod) %
          mod;
    if (c1 > 1)
      ret = (ret + 1LL * f(c1 - 2, c2 - j) * (c1 - 1) % mod * choose[c2][j] %
                       mod * fat[j + 1] % mod) %
            mod;
  }
  return ret;
}
int main(void) {
  ios::sync_with_stdio(false);
  prep();
  cin >> n;
  int c1 = 0, c2 = 0;
  for (int(i) = (0); (i) < (n); ++(i)) {
    cin >> v[i];
    if (v[i] == 1)
      c1++;
    else
      c2++;
  }
  memset(dp, -1, sizeof dp);
  long long ans = f(c1, c2);
  cout << ans << endl;
  return 0;
}
