#include <bits/stdc++.h>
using namespace std;
const int M = (int)1e6 + 5, P = (int)1e9 + 7;
int fast(int x, int p) {
  int re = 1;
  while (p) {
    if (p & 1) re = (long long)re * x % P;
    x = (long long)x * x % P, p >>= 1;
  }
  return re;
}
int n, a, b, fac[M], rfac[M], dp[M];
int main() {
  fac[0] = 1;
  for (int i = 1; i < M; i++) fac[i] = (long long)fac[i - 1] * i % P;
  rfac[M - 1] = fast(fac[M - 1], P - 2);
  for (int i = M - 2; i >= 0; i--)
    rfac[i] = (long long)rfac[i + 1] * (i + 1) % P;
  scanf("%d", &n);
  for (int i = 1, x; i <= n; i++) scanf("%d", &x), (x == 1) ? a++ : b++;
  dp[0] = dp[1] = 1;
  for (int i = 2; i <= a; i++)
    dp[i] = (dp[i - 1] + (long long)dp[i - 2] * (i - 1)) % P;
  cout << (long long)dp[a] * fac[n] % P * rfac[a] % P << endl;
  return 0;
}
