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