#include <bits/stdc++.h>
using namespace std;
inline long long read() {
  long long sum = 0, ff = 1;
  char ch = getchar();
  while (!isdigit(ch)) {
    if (ch == '-') ff = -1;
    ch = getchar();
  }
  while (isdigit(ch)) sum = sum * 10 + (ch ^ 48), ch = getchar();
  return sum * ff;
}
inline void write(long long x) {
  if (x == 0) {
    putchar('0');
    return;
  }
  char F[200];
  long long tmp = x > 0 ? x : -x, cnt = 0;
  if (x < 0) putchar('-');
  while (tmp > 0) F[cnt++] = tmp % 10 + '0', tmp /= 10;
  while (cnt > 0) putchar(F[--cnt]);
}
const long long N = 1e6 + 5;
const long long mod = 1e9 + 7;
long long n, sum1, sum2, f[N];
signed main() {
  n = read();
  for (long long i = 1; i <= n; i++) {
    long long x = read();
    if (x == 1)
      sum1++;
    else
      sum2++;
  }
  f[0] = f[1] = 1;
  for (long long i = 2; i <= sum1; i++)
    f[i] = (f[i - 1] + f[i - 2] * (i - 1) % mod) % mod;
  long long sum = 1;
  for (long long i = 1; i <= sum2; i++) sum = sum * (n - i + 1) % mod;
  write(sum * f[sum1] % mod);
  return 0;
}
