#include <bits/stdc++.h>
using namespace std;
int n, c1, c2;
long long fac[1000005], dp[1000005], ans;
long long pw(long long x, long long y) {
  long long re = 1, tmp = x;
  while (y) {
    if (y & 1) re *= tmp;
    tmp *= tmp;
    re %= 1000000007;
    tmp %= 1000000007;
    y >>= 1;
  }
  return re;
}
int main() {
  fac[0] = 1;
  for (int i = 1; i <= 1000005 - 1; i++) fac[i] = fac[i - 1] * i % 1000000007;
  dp[0] = dp[1] = 1;
  for (int i = 2; i <= 1000005 - 1; i++)
    dp[i] = (dp[i - 1] + (i - 1) * dp[i - 2]) % 1000000007;
  int x;
  while (~scanf("%d", &n)) {
    c1 = c2 = 0;
    for (int i = 1; i <= n; i++) {
      scanf("%d", &x);
      if (x == 1)
        c1++;
      else
        c2++;
    }
    ans = dp[c1] * fac[c1 + c2] % 1000000007;
    ans = ans * pw(fac[c1], 1000000007 - 2) % 1000000007;
    printf("%I64d\n", ans);
  }
  return 0;
}
