#include <bits/stdc++.h>
long long int const MOD = 1000000007;
long long int const N = 1000005;
long long int const LN = 20;
long long int const inf = 8e18;
using namespace std;
long long int n, m, a[N];
long long int dp[N];
long long int fact[N];
long long int ifact[N];
long long int bexpo(long long int x, long long int n, long long int m) {
  long long int r = 1;
  x = x % m;
  while (n > 0) {
    if (n % 2) r = (r * x) % m;
    x = (x * x) % m;
    n = n / 2;
  }
  return r;
}
long long int ncr(long long int n, long long int r) {
  if (r > n) return 0;
  long long int ans = fact[n];
  ans = (ans * ifact[r]) % MOD;
  ans = (ans * ifact[n - r]) % MOD;
  return ans;
}
void pre() {
  fact[0] = 1;
  ifact[0] = 1;
  for (long long int i = 1; i < N; i++) fact[i] = (fact[i - 1] * i) % MOD;
  ifact[N - 1] = bexpo(fact[N - 1], MOD - 2, MOD);
  for (long long int i = N - 2; i > 0; i--)
    ifact[i] = (ifact[i + 1] * (i + 1)) % MOD;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  pre();
  long long int n;
  cin >> n;
  long long int cnt1 = 0;
  long long int cnt2 = 0;
  for (long long int i = 1; i <= n; i++) {
    long long int d;
    cin >> d;
    if (d == 1) cnt1++;
    if (d == 2) cnt2++;
  }
  dp[0] = 1;
  for (long long int i = 1; i <= cnt1; i++)
    dp[i] = (dp[i - 1] + (i - 1) * dp[i - 2]) % MOD;
  long long int ans = dp[cnt1];
  ans *= fact[cnt1 + cnt2];
  ans %= MOD;
  ans *= ifact[cnt1];
  ans %= MOD;
  cout << ans;
  return 0;
}
