#include <bits/stdc++.h>
using namespace std;
template <typename T>
void read(T &n) {
  n = 0;
  T f = 1;
  char c = getchar();
  while (!isdigit(c) && c != '-') c = getchar();
  if (c == '-') f = -1, c = getchar();
  while (isdigit(c)) n = n * 10 + c - '0', c = getchar();
  n *= f;
}
int n, m;
int a[1000005];
long long fac[1000005], inv[1000005];
void init() {
  fac[0] = inv[0] = inv[1] = 1;
  for (int i = 1; i < 1000005; i++)
    fac[i] = fac[i - 1] * i % ((long long)1e9 + 7);
  for (int i = 2; i < 1000005; i++)
    inv[i] = (((long long)1e9 + 7) - ((long long)1e9 + 7) / i) *
             inv[((long long)1e9 + 7) % i] % ((long long)1e9 + 7);
  for (int i = 2; i < 1000005; i++)
    inv[i] = inv[i - 1] * inv[i] % ((long long)1e9 + 7);
}
long long C(int n, int m) {
  if (m > n) return 0;
  if (!m) return 1;
  return fac[n] * inv[m] % ((long long)1e9 + 7) * inv[n - m] %
         ((long long)1e9 + 7);
}
int main() {
  init();
  cin >> n;
  for (int i = 1; i <= n; i++) {
    read(a[i]);
  }
  int len = n;
  n = m = 0;
  for (int i = 1; i <= len; i++) {
    if (a[i] == 1)
      n++;
    else
      m++;
  }
  long long ans = 1, s = 1;
  for (int i = 1; i * 2 <= n; i++) {
    s = s * C(n - (i - 1) * 2, 2) % ((long long)1e9 + 7) * inv[i] %
        ((long long)1e9 + 7) * fac[i - 1] % ((long long)1e9 + 7);
    ans = (ans + s) % ((long long)1e9 + 7);
  }
  for (int i = 1; i <= m; i++) {
    ans = ans * (n + m - i + 1) % ((long long)1e9 + 7);
  }
  cout << ans << endl;
  return 0;
}
