#include <bits/stdc++.h>
using namespace std;
const long double eps = 1e-9;
const int inf = (1 << 30) - 1;
const long long inf64 = ((long long)1 << 62) - 1;
const long double pi = 3.1415926535897932384626433832795;
template <class T>
T sqr(T x) {
  return x * x;
}
template <class T>
T abs(T x) {
  return x < 0 ? -x : x;
}
const int mod = 1000000007;
long long sum(long long a, long long b) { return (a + b) % mod; }
long long prod(long long a, long long b) { return (a * b) % mod; }
int main() {
  int n, n1 = 0, n2 = 0;
  cin >> n;
  for (int i = 0; i < n; ++i) {
    int t;
    cin >> t;
    if (t == 1)
      n1++;
    else
      n2++;
  }
  long long m = 1;
  long long m_old = 1;
  for (int i = 2; i <= n1; ++i) {
    long long m_new = sum(m, prod(m_old, i - 1));
    m_old = m;
    m = m_new;
  }
  for (int i = 0; i < n2; ++i) {
    m = prod(m, n1 + i + 1);
  }
  cout << m << endl;
  return 0;
}
