#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
const long long maxn = 5e6 + 10;
long long T, n;
long long fac[maxn], inv[maxn], pw2[maxn];
inline long long fpw(long long a, long long b) {
  long long res = 1;
  while (b) {
    if (b & 1) res = 1ll * res * a % mod;
    a = 1ll * a * a % mod, b >>= 1;
  }
  return res;
}
signed main() {
  long long Inv = fpw(2, mod - 2);
  fac[0] = inv[0] = pw2[0] = 1;
  for (long long i = 1; i <= maxn - 5; i++) {
    fac[i] = (1ll * fac[i - 1] * i) % mod;
    pw2[i] = (1ll * Inv * pw2[i - 1]) % mod;
  }
  inv[maxn - 5] = fpw(fac[maxn - 5], mod - 2);
  for (long long i = maxn - 6; i; i--)
    inv[i] = (1ll * inv[i + 1] * (i + 1)) % mod;
  long long sum = 0;
  scanf("%lld", &n);
  for (long long i = 1, x; i <= n; i++) {
    scanf("%lld", &x);
    sum += x == 1;
  }
  long long ans = 0;
  for (long long i = (sum - 1) / 2 + 1; i <= sum; i++)
    (ans += 1ll * fac[sum] * inv[2 * i - sum] % mod * pw2[sum - i] % mod *
            inv[sum - i] % mod) %= mod;
  if (!sum) ans++;
  (ans *= (1ll * fac[n] * inv[sum]) % mod) %= mod;
  printf("%lld\n", ans);
}
