#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9 + 7;
const int MAXN = 1000010;
long long T = 1;
long long f[MAXN];
long long cf[MAXN];
int N;
int a, b;
long long _pow(long long a, long long b) {
  long long ret = 1;
  while (b) {
    if (b & 1) ret = (ret * a) % MOD;
    b >>= 1;
    a = (a * a) % MOD;
  }
  return ret;
}
long long g(long long a) { return _pow(a, MOD - 2); }
long long comb(int n, int r) {
  return ((f[n] * cf[n - r]) % MOD * cf[r]) % MOD;
}
int main() {
  cin >> N;
  for (int i = 1; i <= N; i++) {
    int x;
    scanf(" %d", &x);
    if (x == 1)
      a++;
    else
      b++;
  }
  f[0] = 1LL;
  for (int i = 1; i <= N; i++) f[i] = (f[i - 1] * i) % MOD;
  for (int i = 0; i <= N; i++) cf[i] = g(f[i]);
  if (a <= 2) {
    cout << f[N] << endl;
    return 0;
  }
  long long A = 1LL, p = 1LL, B = 0LL;
  for (int i = 1; i <= a / 2; i++) {
    T = (T * comb(a - i * 2 + 2, 2)) % MOD;
    A += (T * cf[i]) % MOD;
    while (A > MOD) A -= MOD;
  }
  long long x = a;
  for (int i = 0; i <= b - 1; i++, x++) p = (p * x) % MOD;
  x--;
  for (int i = 0; i <= b; i++) {
    B += ((comb(b, i) * f[i]) % MOD * p) % MOD;
    B %= MOD;
    p = (p * g(x)) % MOD;
    x--;
  }
  cout << (A * B) % MOD << endl;
  return 0;
}
