#include <bits/stdc++.h>
using namespace std;
namespace IO {
inline char ch() {
  static char s[1 << 16], *S, *T;
  return (S == T) && (T = (S = s) + fread(s, 1, 1 << 16, stdin), S == T) ? EOF
                                                                         : *S++;
}
template <typename T>
void read(T &x) {
  x = 0;
  int f(1);
  char c = ch();
  for (; !isdigit(c); c = ch())
    if (c == '-') f = -1;
  for (; isdigit(c); c = ch()) x = x * 10 + c - '0';
  x *= f;
}
}  // namespace IO
using namespace IO;
const int maxn = 1000003;
const long long p = 1000000007;
const long long inv2 = (p + 1) / 2;
int n, m1, m2;
long long f[maxn];
int main() {
  read(n);
  for (int i(1); i <= n; ++i) {
    int x;
    read(x);
    if (x == 1)
      ++m1;
    else
      ++m2;
  }
  f[1] = f[0] = 1;
  for (int i(2); i <= m1; ++i) f[i] = (f[i - 2] * (i - 1) % p + f[i - 1]) % p;
  for (int i = m1 + 1; i <= n; ++i) f[m1] = f[m1] * i % p;
  cout << f[m1] << endl;
  return 0;
}
