#include <bits/stdc++.h>
using namespace std;
const long long ff = 1e6 + 1;
const long long inf = 1e18 + 1;
const long long M = 1e9 + 7;
long long n, t[ff];
long long su[ff], Ans;
long long f[501][501], g[501], h[501], hh[501][501], r[501];
void work2() {
  long long sumw = n - su[n];
  g[0] = 1;
  for (long long i = 1; i <= sumw; ++i) {
    for (long long k = 0; k <= sumw; ++k) h[k] = g[k], g[k] = 0;
    for (long long k = 0; k <= sumw; ++k) g[k] = h[k] * (su[n] + i - 1) % M;
    for (long long k = 0; k <= sumw - 1; ++k) (g[k + 1] += h[k]) %= M;
  }
  for (long long j = 0; j <= n; ++j)
    for (long long k = 0; k <= n; ++k) (r[j] += g[k]) %= M;
  f[0][0] = 1;
  for (long long i = 1; i <= su[n]; ++i) {
    for (long long j = 0; j <= i; ++j)
      for (long long k = 0; k <= i - j; ++k) hh[j][k] = f[j][k], f[j][k] = 0;
    for (long long j = 0; j <= i - 1; ++j)
      for (long long k = 0; k <= i - j; ++k) f[j + 1][k] = hh[j][k];
    for (long long j = 1; j <= i; ++j)
      for (long long k = 0; k <= i - j - 1; ++k)
        (f[j - 1][k + 1] += hh[j][k] * j) %= M;
  }
  for (long long j = 0; j <= su[n]; ++j)
    for (long long k = 0; k <= su[n]; ++k)
      Ans = (Ans + f[j][k] * r[j + k] % M) % M;
  cout << Ans << "\n";
}
void init() {
  Ans = 0;
  memset(f, 0, sizeof(f));
  memset(g, 0, sizeof(g));
  memset(h, 0, sizeof(h));
  memset(r, 0, sizeof(r));
  cin >> n;
  for (long long i = 1; i <= n; ++i)
    scanf("%lld", &t[i]), su[i] = su[i - 1] + (t[i] == 1);
  return (void)(work2());
}
signed main() {
  long long Ts = 1;
  while (Ts--) init();
}
