#include <bits/stdc++.h>
using namespace std;
int i, j, k, n, m, n1, n2;
long long h[1000010], v[1000010], an, re, w[1000010];
inline long long pow(long long x, long long y) {
  long long an = 1;
  for (; y; y >>= 1) {
    if (y & 1) an = an * x % 1000000007;
    x = x * x % 1000000007;
  }
  return an;
}
inline long long C(int n, int m) {
  return h[n] * v[m] % 1000000007 * v[n - m] % 1000000007;
}
int main() {
  scanf("%d", &n);
  for (i = 1; i <= n; i++) {
    scanf("%d", &k);
    if (k == 1) n1++;
    if (k > 1) n2++;
  }
  h[0] = v[0] = 1;
  for (i = 1; i <= n; i++)
    h[i] = h[i - 1] * i % 1000000007, v[i] = pow(h[i], 1000000007 - 2);
  w[0] = 1;
  for (i = 1; i <= n; i++) w[i] = w[i - 1] * 2 % 1000000007;
  for (i = 1; i <= n; i++) w[i] = pow(w[i], 1000000007 - 2);
  for (i = 0; i <= n1 / 2; i++)
    an += C(n1, i) * C(n1 - i, i) % 1000000007 * h[i] % 1000000007 * w[i] %
          1000000007;
  an %= 1000000007;
  int k = n1 ? n2 : 0;
  for (i = 0; i <= k; i++)
    re += (n1 ? h[n1 + i - 1] * v[n1 - 1] : 1) % 1000000007 * C(n2, i) %
          1000000007 * h[n2 - i] % 1000000007;
  re %= 1000000007;
  printf("%I64d\n", an * re % 1000000007);
  return 0;
}
