#include <bits/stdc++.h>
using namespace std;
const double pi = acos(-1.0);
const int size = 1000 * 1000;
const long long mdl = 1000 * 1000 * 1000 + 7;
long long ans[size + 1];
int nums[size];
long long fact[size * 2 + 1];
int n;
set<vector<int> > could;
void rec(vector<int> &h1, vector<int> &h2) {
  could.insert(h1);
  for (int i = 0; i < n; i++)
    for (int j = i + 1; j < n; j++)
      if (h2[i] > 0 && h2[j] > 0) {
        swap(h1[i], h1[j]);
        h2[i]--;
        h2[j]--;
        rec(h1, h2);
        swap(h1[i], h1[j]);
        h2[j]++;
        h2[i]++;
      }
}
int main() {
  scanf("%d", &n);
  int c[2];
  c[0] = c[1] = 0;
  for (int i = 0; i < n; i++) {
    scanf("%d", &nums[i]);
    c[nums[i] - 1]++;
  }
  fact[0] = 1;
  for (int i = 1; i < 2 * size; i++) fact[i] = (fact[i - 1] * i) % mdl;
  ans[0] = 1;
  ans[1] = 1;
  ans[2] = 2;
  for (int i = 3; i <= c[0]; i++) {
    ans[i] = (ans[i - 1] + ans[i - 2] * (i - 1)) % mdl;
  }
  for (int i = 1; i <= c[1]; i++) ans[c[0]] = (ans[c[0]] * (c[0] + i)) % mdl;
  cout << ans[c[0]] << endl;
  return 0;
}
