#include <bits/stdc++.h>
using namespace std;
int n;
int maxTimes[101];
int x[101];
int ans;
map<vector<int>, bool> occur;
map<vector<int>, bool> have;
void solve() {
  vector<int> cur;
  for (int i = 1; i <= n; i++) cur.push_back(x[i]);
  vector<int> state = cur;
  for (int i = 1; i <= n; i++) state.push_back(maxTimes[i]);
  if (have[state]) return;
  have[state] = true;
  if (occur[cur] == false) {
    occur[cur] = true;
    ans++;
  }
  for (int i = 1; i <= n; i++)
    for (int j = i + 1; j <= n; j++)
      if (maxTimes[i] > 0 && maxTimes[j] > 0) {
        maxTimes[i]--;
        maxTimes[j]--;
        swap(x[i], x[j]);
        solve();
        swap(x[i], x[j]);
        maxTimes[i]++;
        maxTimes[j]++;
      }
}
long long magic[1000011];
long long mod = 1000000007LL;
long long power(long long a, long long b) {
  long long ret = 1;
  while (b) {
    if (b & 1) ret = (ret * a) % mod;
    a = (a * a) % mod;
    b /= 2;
  }
  return ret;
}
long long inv(long long x) { return power(x, mod - 2); }
int MAIN() {
  magic[1] = 1;
  magic[2] = 2;
  for (int i = 3; i <= 1000010; i++)
    magic[i] = (magic[i - 1] + magic[i - 2] * i) % mod;
  while (cin >> n) {
    int cnt2 = 0;
    for (int i = 1; i <= n; i++) {
      int t;
      cin >> t;
      if (t == 2) cnt2++;
    }
    long long ans = 1;
    for (int i = 1; i <= n; i++) ans = (ans * i) % mod;
    int needs = n - 2 - cnt2;
    if (needs > 0) {
      int idx = 2;
      while (needs > 0) {
        ans = (ans * magic[idx]) % mod;
        ans = (ans * inv((magic[idx + 1] - magic[idx] + mod) % mod)) % mod;
        needs--;
        idx++;
      }
    }
    cout << ans << endl;
  }
  return 0;
}
int main() {
  ios ::sync_with_stdio(false);
  cout << fixed << setprecision(16);
  return MAIN();
}
