#include <bits/stdc++.h>
using namespace std;
long long dp[1000005];
long long a, b, x, y, z, r, res;
long long mod = 1000000007;
int i, j, k, n, m, t;
int main() {
  scanf("%d", &n);
  for (i = 0; i < n; i++) {
    scanf("%d", &t);
    if (t == 1) {
      a++;
    } else {
      b++;
    }
  }
  if (n == 1) {
    cout << 1 << endl;
    return 0;
  }
  if (b >= n - 2) {
    b = n - 2;
    a = 2;
  }
  dp[1] = 1;
  dp[2] = 2;
  for (i = 3; i < 1000005; i++) {
    dp[i] = (dp[i - 1] + dp[i - 2] * (i - 1)) % mod;
  }
  r = dp[n - b];
  for (j = 1; j <= b; j++) {
    r = (r * (a + j)) % mod;
  }
  cout << r << endl;
  return 0;
}
