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