#include <bits/stdc++.h>
using namespace std;
const int maxn = 1000000 + 10;
const int md = 1000000007;
int d[maxn], a[maxn], cnt1, cnt2, n;
long long f[maxn];
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    if (a[i] == 1)
      cnt1++;
    else
      cnt2++;
  }
  long long res = 1;
  for (int i = 1; i <= cnt2; i++) res = (res * (long long)(n - i + 1)) % md;
  f[0] = f[1] = 1;
  for (int i = 2; i <= n - cnt2; i++)
    f[i] = (f[i - 1] + (long long)(i - 1) * f[i - 2] % md) % md;
  res = (res * f[n - cnt2]) % md;
  cout << res << endl;
  return 0;
}
