#include <bits/stdc++.h>
using namespace std;
inline long long read() {
  long long x = 0, f = 1;
  char ch = getchar();
  while (ch > '9' || ch < '0') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = (x << 1) + (x << 3) + (ch ^ 48);
    ch = getchar();
  }
  return x * f;
}
const long long N = 1010, mod = 1e9 + 7;
long long n, t[3] = {};
long long ans = 1, a, b, c;
signed main() {
  long long T;
  t[1] = t[2] = 0;
  ans = 1;
  n = read();
  for (long long i = 1, x = 0; i <= n; ++i) {
    x = read();
    ++t[x];
  }
  for (long long i = t[1] + 1; i <= t[1] + t[2]; ++i) {
    ans = ans * i % mod;
  }
  a = 1, b = 1;
  for (long long i = 2; i <= t[1]; ++i) {
    c = (b + (i - 1) * a) % mod;
    a = b, b = c;
  }
  printf("%lld", ans * b % mod);
  return 0;
}
