#include <bits/stdc++.h>
using namespace std;
const int inf = (int)1e9;
const double eps = 1e-9;
long long dp[1000][1000];
long long cnk[1000][1000];
long long f[1000];
const int md = (int)1e9 + 7;
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i <= n; i++) {
    cnk[i][0] = 1;
    f[i] = (i == 0) ? 1 : ((long long)f[i - 1] * i) % md;
    for (int j = 1; j <= i; j++) {
      cnk[i][j] = (cnk[i - 1][j - 1] + cnk[i - 1][j]) % md;
    }
  }
  int c1 = 0, c2 = 0;
  for (int i = 0; i < n; i++) {
    int first;
    scanf("%d", &first);
    if (first == 1) {
      c1++;
    } else {
      c2++;
    }
  }
  for (int i = 0; i <= c1; i++) {
    for (int j = 0; j <= c2; j++) {
      if (i + j <= 1) {
        dp[i][j] = 1;
        continue;
      }
      if (i > 0) {
        for (int i1 = 0; i1 + 1 <= min(2, i); i1++) {
          for (int j1 = 0; j1 <= j; j1++) {
            if (i1 == 0) {
              dp[i][j] =
                  (dp[i][j] + (cnk[j][j1] * f[j1]) % md * dp[i - 1][j - j1]) %
                  md;
            } else {
              dp[i][j] =
                  (dp[i][j] +
                   ((j1 + 1) * cnk[i - 1][i1]) % md *
                       (((cnk[j][j1] * f[j1]) % md * dp[i - 2][j - j1]) % md)) %
                  md;
            }
          }
        }
      } else {
        dp[i][j] = f[j];
      }
    }
  }
  cout << dp[c1][c2] << endl;
  return 0;
}
