#include <bits/stdc++.h>
using namespace std;
long long a = 0, b = 0, n, d[505][505], c[505][505], f[505], r[505];
void read(void) {
  cin >> n;
  for (int x, i = 0; i < n; ++i) {
    cin >> x;
    if (x == 1)
      a++;
    else
      b++;
  }
}
void din(void) {
  for (int i = 0; i < 505; ++i) c[i][0] = 1;
  for (int i = 1; i < 505; ++i)
    for (int j = 1; j < 505; ++j) c[i][j] = (i * c[i - 1][j - 1]) % 1000000007;
  d[0][0] = 1;
  for (int j = 1; j < 505; ++j) d[0][j] = (j * d[0][j - 1]) % 1000000007;
  for (int i = 1; i < 505; ++i)
    for (int j = 0; j < 505; ++j)
      if (i + j < 505)
        for (long long k = 0; k <= j; ++k) {
          d[i][j] += (c[j][k] * d[i - 1][j - k]);
          long long bon = (c[j][k] * (i - 1)) % 1000000007;
          bon = (bon * (k + 1)) % 1000000007;
          if (i >= 2) d[i][j] += (bon * d[i - 2][j - k]);
          d[i][j] %= 1000000007;
        }
}
long long bin(long long x, long long a) {
  long long y = 1;
  while (a) {
    if (x & 1) y *= x, y %= 1000000007;
    x *= x, x %= 1000000007;
    a >>= 1;
  }
  return y;
}
void pre(void) {
  f[1] = 1;
  for (int i = 2; i < 505; ++i) f[i] = (i * f[i - 1]) % 1000000007;
  r[0] = r[1] = 1;
  for (int i = 2; i < 505; ++i) r[i] = ((2 * i - 1) * r[i - 1]) % 1000000007;
  long long ans = 0;
  for (int x = a % 2; x <= a; x += 2) {
    int k = ((a + x) / 2);
    long long bon = (r[k] * f[b]) % 1000000007;
    bon = (bon * bin(b, k + 1)) % 1000000007;
    ans = (ans + bon) % 1000000007;
  }
  cout << ans << "\n";
}
int main() {
  din();
  read();
  cout << d[a][b] << "\n";
  return 0;
}
