#include <bits/stdc++.h>
using namespace std;
const long long N = 1e6 + 100, P = 1e9 + 7;
long long t, n;
long long cnt1 = 0, cnt2 = 0;
long long f[N];
void work() {
  scanf("%lld", &n);
  cnt1 = cnt2 = 0;
  for (long long i = 1, x; i <= n; i++)
    scanf("%lld", &x), x == 1 ? cnt1++ : cnt2++;
  long long ans = 1;
  for (long long i = cnt1 + 1; i <= cnt2 + cnt1; i++) ans = ans * 1ll * i % P;
  f[0] = f[1] = 1;
  for (long long i = 2; i <= cnt1; i++)
    f[i] = (f[i - 2] * 1ll * (i - 1) % P + f[i - 1]) % P;
  printf("%lld\n", f[cnt1] * 1ll * ans % P);
  return;
}
signed main() {
  work();
  return 0;
}
