#include <bits/stdc++.h>
const int N = 1e6 + 6, mod = 1e9 + 7;
int n, sum[3];
inline int read() {
  int s = 0, f = 1;
  char ch;
  for (; ch < '0' || ch > '9'; ch = getchar())
    if (ch == '-') f = -1;
  for (; ch >= '0' && ch <= '9'; ch = getchar())
    s = (s << 1) + (s << 3) + ch - '0';
  return s * f;
}
inline int add(int a, int b) { return (a += b) >= mod ? a - mod : a; }
inline int sub(int a, int b) { return (a -= b) < 0 ? a + mod : a; }
inline int mul(int a, int b) { return 1LL * a * b % mod; }
inline void Add(int &a, int b) { a = add(a, b); }
inline void Sub(int &a, int b) { a = sub(a, b); }
inline void Mul(int &a, int b) { a = mul(a, b); }
inline int quickpow(int a, int b) {
  int re = 1;
  while (b) {
    if (b & 1) Mul(re, a);
    b >>= 1;
    Mul(a, a);
  }
  return re;
}
int fac[N + 1], inv[N + 1], f[N + 1];
inline void input() {
  fac[0] = 1;
  for (int i = 1; i <= N; ++i) fac[i] = mul(fac[i - 1], i);
  inv[N] = quickpow(fac[N], mod - 2);
  for (int i = N; i >= 1; --i) inv[i - 1] = mul(inv[i], i);
  f[0] = f[1] = 1, f[2] = 2;
  for (int i = 3; i <= N; ++i) f[i] = add(mul(f[i - 2], (i - 1)), f[i - 1]);
}
inline int C(int n, int m) {
  if (n < m || n < 0 || m < 0) return 0;
  return mul(fac[n], mul(inv[m], inv[n - m]));
}
int main() {
  input();
  for (int _ = 1; _; --_) {
    n = read();
    sum[1] = sum[2] = 0;
    for (int i = 1; i <= n; ++i) ++sum[read()];
    printf("%d\n", mul(mul(fac[n], inv[sum[1]]), f[sum[1]]));
  }
  return 0;
}
