#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1 << 20;
const long long MOD = 1000000007;
long long n, x, y;
long long dp[MAXN];
long long ans;
void read() {
  int a;
  scanf("%I64d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a);
    if (a == 1)
      x++;
    else
      y++;
  }
}
void solve() {
  dp[1] = 1;
  dp[2] = 2;
  dp[3] = 4;
  for (long long i = 4; i <= n; i++)
    dp[i] = (dp[i - 1] + ((i - 1) * dp[i - 2]) % MOD) % MOD;
  if (!x) {
    ans = 1;
    for (long long i = 1; i <= n; i++) ans = (ans * i) % MOD;
    cout << ans << endl;
    return;
  }
  if (!y) {
    cout << dp[x] << endl;
    return;
  }
  ans = dp[x];
  x++;
  for (int i = 1; i <= y; i++) {
    ans = (ans * x) % MOD;
    x++;
  }
  cout << ans << endl;
}
int main() {
  read();
  solve();
  return 0;
}
