#include <bits/stdc++.h>
using namespace std;
using LL = long long;
namespace _buff {
const size_t BUFF = 1 << 19;
char buff[BUFF], *begin = buff, *end = buff;
char getc() {
  if (begin == end) {
    begin = buff;
    end = buff + fread(buff, 1, BUFF, stdin);
  }
  return begin == end ? -1 : *begin++;
}
}  // namespace _buff
LL read() {
  using namespace _buff;
  LL ret = 0;
  bool pos = true;
  char c = getc();
  for (; (c < '0' || c > '9') && c != '-'; c = getc()) {
    assert(~c);
  }
  if (c == '-') {
    pos = false;
    c = getc();
  }
  for (; c >= '0' && c <= '9'; c = getc()) {
    ret = (ret << 3) + (ret << 1) + (c ^ 48);
  }
  return pos ? ret : -ret;
}
const size_t N = 100 + 5;
const int MOD = 1e9 + 7;
void add(int &dp, LL val) { dp = (dp + val) % MOD; }
int f[N][N], g[N][N][N], cnt3[N], d[N];
LL getG(int i, int j, int k) {
  if (i < 0 || j < 0 || k < 0) return 0;
  return g[i][j][k];
}
int main() {
  int n = read();
  for (int i = 1; i <= n; ++i) {
    cnt3[i] = cnt3[i - 1] + ((d[i] = read()) & 1);
  }
  g[0][0][0] = 1;
  for (int c0 = 0; c0 <= n; ++c0) {
    for (int c2 = 0; c2 <= n; ++c2) {
      for (int c1 = !c2; c1 <= n; ++c1) {
        int &cg = g[c0][c1][c2];
        if (c2 > 0) {
          add(cg, getG(c0 - 2, c1, c2 - 1) * c0 * (c0 - 1) / 2);
          add(cg, getG(c0 - 1, c1 + 1, c2 - 2) * c0 * (c2 - 1));
          add(cg, getG(c0, c1 + 2, c2 - 3) * (c2 - 1) * (c2 - 2) / 2);
          add(cg, getG(c0, c1, c2 - 2) * (c2 - 1) * c1);
          add(cg, getG(c0 - 1, c1 - 1, c2 - 1) * c0 * c1);
          add(cg, getG(c0, c1 - 2, c2 - 1) * c1 * (c1 - 1) / 2);
        } else {
          add(cg, getG(c0 - 1, c1 - 1, c2) * c0);
          add(cg, getG(c0, c1 - 2, c2) * (c1 - 1));
        }
      }
    }
  }
  f[n + 1][n] = 1;
  for (int l = n; l >= 2; --l) {
    for (int r = l; r <= n; ++r) {
      int c2 = cnt3[r] - cnt3[l - 1];
      int c1 = r - l + 1 - c2;
      for (int k = 0; k + r <= n; ++k) {
        add(f[l][r], static_cast<LL>(f[r + 1][r + k]) * g[k][c1][c2]);
      }
    }
  }
  printf("%d\n", f[2][d[1] + 1]);
  return 0;
}
