#include <bits/stdc++.h>
using namespace std;
inline bool EQ(double a, double b) { return fabs(a - b) < 1e-9; }
const int INF = 1 << 29;
inline int two(int n) { return 1 << n; }
inline int test(int n, int b) { return (n >> b) & 1; }
inline void set_bit(int& n, int b) { n |= two(b); }
inline void unset_bit(int& n, int b) { n &= ~two(b); }
inline int last_bit(int n) { return n & (-n); }
inline int ones(int n) {
  int res = 0;
  while (n && ++res) n -= n & (-n);
  return res;
}
template <class T>
void chmax(T& a, const T& b) {
  a = max(a, b);
}
template <class T>
void chmin(T& a, const T& b) {
  a = min(a, b);
}
const long long MOD = 1000000007;
const int MAX = 507;
int N, in[MAX];
long long fact[MAX], ifact[MAX];
template <class T>
T power(T x, T y, T mod) {
  T res = 1;
  while (y) {
    if (y & 1) res = (res * x) % mod;
    x = (x * x) % mod;
    y >>= 1;
  }
  return res;
}
template <class T>
T inverse(T x, T p) {
  return power(x, p - 2, p);
}
long long comb(int N, int K) {
  if (K < 0 || K > N) return 0;
  return fact[N] * ifact[K] % MOD * ifact[N - K] % MOD;
}
long long dp[MAX][MAX][3];
long long go(int n1, int n2, int ph) {
  if (!n1 && !n2) return 1;
  long long& res = dp[n1][n2][ph];
  if (res != -1) return res;
  res = 0;
  for (int i = (1); i <= (min(n1, ph)); i++)
    for (int j = (0); j <= (n2); j++) {
      long long act =
          go(n1 - i, n2 - j, ph) * comb(n2, j) % MOD * fact[i + j - 1] % MOD;
      if (i == 2) act = act * (n1 - 1) % MOD;
      res = (res + act) % MOD;
    }
  if (!n1) {
    for (int j = (1); j <= (n2); j++) {
      long long act =
          go(0, n2 - j, 0) * comb(n2 - 1, j - 1) % MOD * fact[j - 1] % MOD;
      res = (res + act) % MOD;
    }
  }
  return res;
}
int main() {
  scanf("%d", &N);
  int n1 = 0, n2 = 0;
  for (int i = 0; i < (N); i++) {
    scanf("%d", &in[i]);
    if (in[i] == 1)
      ++n1;
    else
      ++n2;
  }
  fact[0] = 1;
  for (int i = (1); i <= (MAX - 1); i++) fact[i] = (fact[i - 1] * i) % MOD;
  ifact[MAX - 1] = inverse(fact[MAX - 1], MOD);
  for (int i = (MAX - 2); i >= (0); i--)
    ifact[i] = (ifact[i + 1] * (i + 1)) % MOD;
  memset(dp, -1, sizeof(dp));
  cout << go(n1, n2, 2) << endl;
  return 0;
}
