#include <bits/stdc++.h>
using namespace std;
const int mod = 1000000007;
int dp[510][510];
int bin[510][510];
int fac[1000100];
inline int add(int a, int b) {
  a += b;
  if (a >= mod) a -= mod;
  return a;
}
inline int mul(int a, int b) { return (a * (long long)b) % mod; }
inline int dpf(int c1, int c2) {
  if (dp[c1][c2] != -1) return dp[c1][c2];
  int &d = dp[c1][c2];
  if (c1 == 0) return d = fac[c2];
  d = 0;
  for (int i = 0; i <= 1 && i <= c1 - 1; i++) {
    for (int j = 0; j <= c2; j++) {
      d = add(d, mul(mul(bin[c1 - 1][i], bin[c2][j]),
                     mul(fac[i + j], dpf(c1 - 1 - i, c2 - j))));
    }
  }
  return d;
}
int main() {
  fac[0] = 1;
  bin[0][0] = 1;
  for (int i = (1); i <= (500); i++) {
    bin[i][0] = bin[i][i] = 1;
    for (int j = (1); j <= (i - 1); j++) {
      bin[i][j] = add(bin[i - 1][j], bin[i - 1][j - 1]);
    }
  }
  for (int i = (1); i <= (1000010); i++) fac[i] = mul(fac[i - 1], i);
  int n;
  scanf("%d", &n);
  int c1 = 0, c2 = 0;
  for (int i = 0; i < (n); i++) {
    int a;
    scanf("%d", &a);
    if (a == 1)
      c1++;
    else
      c2++;
  }
  memset(dp, -1, sizeof(dp));
  printf("%d\n", dpf(c1, c2));
}
