#include <bits/stdc++.h>
using namespace std;
const int MOD = 1000000007;
int I(int64_t n) {
  int p0 = 1, p1 = 1;
  for (int64_t i = 2; i <= n; ++i) {
    p0 = (p1 + (i - 1) * p0 % MOD) % MOD;
    swap(p0, p1);
  }
  return p1;
}
int P(int n, int k) {
  int64_t p = 1;
  for (int i = 0; i < k; ++i) p = p * (n - i) % MOD;
  return p;
}
int f(int a, int b) { return int64_t(P(a + b, b)) * I(a) % MOD; }
void solve(istream &in, ostream &out) {
  int n;
  in >> n;
  int a = 0, b = 0;
  for (int i = 0; i < n; ++i) {
    int c;
    in >> c;
    if (c == 1)
      ++a;
    else
      ++b;
  }
  out << f(a, b) << endl;
}
int main() {
  solve(cin, cout);
  return 0;
}
