#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 5, P = 1e9 + 7;
int n, c1;
long long f[N];
int main() {
  int T = 1;
  while (T--) {
    memset(f, 0, sizeof(f));
    scanf("%d", &n);
    c1 = 0;
    for (int i = 1, x; i <= n; i++) scanf("%d", &x), c1 = x == 1 ? c1 + 1 : c1;
    f[0] = f[1] = 1;
    for (int i = 2; i <= c1; i++)
      f[i] = (f[i - 1] + (i - 1) * f[i - 2] % P) % P;
    long long ans = 1;
    for (int i = c1 + 1; i <= n; i++) (ans *= i) %= P;
    printf("%lld\n", ans * f[c1] % P);
  }
  return 0;
}
