#include <bits/stdc++.h>
using namespace std;
const long long inf = 2e18 + 7;
const long long mod = 1e9 + 7;
const double eps = 1e-12;
const double PI = 2 * acos(0.0);
const double E = 2.71828;
int n, a, b;
int f[100005];
int main(void) {
  scanf("%d", &n);
  for (int(i) = 0; (i) < (n); ++(i)) {
    int x;
    scanf("%d", &x);
    if (x == 1)
      ++a;
    else
      ++b;
  }
  f[0] = 1;
  f[1] = 1;
  for (int i = 2; i <= a; ++i) {
    f[i] = (f[i - 1] + 1LL * (i - 1) * f[i - 2]) % mod;
  }
  int res = f[a];
  for (int i = 0, cnt = a + 1; i < b; ++i, ++cnt) {
    res = (1LL * res * cnt) % mod;
  }
  printf("%d\n", res);
  return 0;
}
