#include <bits/stdc++.h>
using namespace std;
inline int read() {
  int f = 1, x = 0;
  char s = getchar();
  while (s < '0' || s > '9') {
    if (s == '-') f = -1;
    s = getchar();
  }
  while (s >= '0' && s <= '9') {
    x = x * 10 + s - 48;
    s = getchar();
  }
  return f * x;
}
const int p = 1e9 + 7;
int dp[1000005];
int main() {
  int n = read();
  int cnt = 0;
  for (int i = 1; i <= n; i++) {
    int a = read();
    cnt += (a == 1);
  }
  dp[0] = dp[1] = 1;
  for (int i = 2; i <= cnt; i++)
    dp[i] = (1ll * dp[i - 2] * (i - 1) % p + dp[i - 1]) % p;
  for (int i = n; i > cnt; i--) dp[cnt] = 1ll * dp[cnt] * i % p;
  printf("%d\n", dp[cnt]);
  return 0;
}
