#include <bits/stdc++.h>
using namespace std;
const long long maxn = 1e6 + 5, Mod = 1e9 + 7;
long long dp[maxn], n, a, b, ans = 1;
long long read() {
  long long x = 0, f = 1;
  char ch = getchar();
  while (ch > '9' || ch < '0') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch <= '9' && ch >= '0') {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return x * f;
}
signed main() {
  n = read();
  for (long long i = 1; i <= n; i++) {
    long long x = read();
    if (x == 1) a++;
  }
  dp[0] = dp[1] = 1;
  for (long long i = 2; i <= a; i++)
    dp[i] = (dp[i - 2] * (i - 1) + dp[i - 1]) % Mod;
  for (long long i = a + 1; i <= n; i++) (ans *= i) %= Mod;
  cout << ans * dp[a] % Mod << endl;
  return 0;
}
