#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
long long n, cnt1, cnt2, ans = 1, f[1000005];
long long read() {
  long long f = 0, w = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') w = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    f = f * 10 + ch - '0';
    ch = getchar();
  }
  return f * w;
}
signed main() {
  n = read();
  for (long long i = 1; i <= n; i++) {
    long long x = read();
    if (x == 1) cnt1++;
  }
  f[0] = 1, f[1] = 1;
  for (long long i = 2; i <= cnt1; i++)
    f[i] = (f[i - 1] + (i - 1) * f[i - 2] % mod) % mod;
  long long ans = f[cnt1];
  for (long long i = n; i > cnt1; i--) ans = ans * i % mod;
  printf("%lld\n", ans);
  return 0;
}
