#include <bits/stdc++.h>
using namespace std;
const long long N = 1e6 + 10, mod = 1e9 + 7;
long long ans = 1, t, n, a, b, f[N];
int main() {
  scanf("%lld", &n);
  f[0] = f[1] = 1;
  for (long long i = 2; i <= n; i++)
    f[i] = (f[i - 1] + f[i - 2] * (i - 1) % mod) % mod;
  for (long long i = 1; i <= n; i++) {
    long long x;
    scanf("%lld", &x);
    if (x == 1)
      a++;
    else
      b++;
  }
  for (long long i = n; i >= n - b + 1; i--) ans = (ans * i) % mod;
  printf("%lld\n", ans * f[a] % mod);
  return 0;
}
