#include <bits/stdc++.h>
using namespace std;
const double pi = acos(-1);
const long long MOD = 1e9 + 7;
const int N = 1e6 + 5;
long long ans[N][3];
void pre() {
  ans[0][0] = ans[0][1] = 1;
  ans[1][0] = 1;
  ans[1][1] = 2;
  for (int i = 1; i <= N - 5; i += 1) {
    ans[i][0] = ans[i - 1][0] + ans[i - 2][1];
    ans[i][0] %= MOD;
    ans[i][1] = (ans[i][0] * (i + 1)) % MOD;
  }
}
int main() {
  ios_base ::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  pre();
  int n;
  cin >> n;
  int cnt = 0, cnt2 = 0, x;
  for (int i = 1; i <= n; i += 1) {
    cin >> x;
    if (x == 1)
      cnt++;
    else
      cnt2++;
  }
  long long ret = ans[cnt][0];
  for (int i = 1; i <= cnt2; i += 1) {
    ret = (ret * (cnt + 1 + i - 1)) % MOD;
  }
  cout << ret << endl;
  return 0;
}
