#include <bits/stdc++.h>
using namespace std;
const long long N = 3e5;
const long long P = 1e9 + 7;
long long n;
long long a[N], f[N];
long long read(void) {
  long long s = 0, w = 0;
  char c = getchar();
  while (!isdigit(c)) w |= c == '-', c = getchar();
  while (isdigit(c)) s = s * 10 + c - 48, c = getchar();
  return w ? -s : s;
}
void work(void) {
  long long res = 1, cnt = 0;
  n = read();
  for (long long i = 1; i <= n; ++i) {
    a[i] = read();
    cnt += a[i] == 1;
  }
  f[0] = f[1] = 1;
  for (long long i = 2; i <= cnt; ++i)
    f[i] = (f[i - 2] * (i - 1) + f[i - 1]) % P;
  for (long long i = n; i > cnt; --i) res = res * i % P;
  cout << f[cnt] * res % P << endl;
  return;
}
signed main(void) {
  work();
  return 0;
}
