#include <bits/stdc++.h>
using namespace std;
long long modu = 1000000007LL;
long long memo[515][515];
long long rundp[2][515][515];
long long Solv(int ones, int twos) {
  long long& alias = memo[ones][twos];
  if (alias != -1LL) return alias;
  if (ones == 0 && twos == 0) return 1LL;
  alias = 0LL;
  if (!ones) {
    alias += Solv(0, twos - 1);
    if (twos > 1) {
      alias += (Solv(1, twos - 2) * (twos - 1)) % modu;
      alias %= modu;
    }
  } else {
    for (int(i) = 0; (i) < (ones + 2); ++(i))
      for (int(j) = 0; (j) < (twos + 2); ++(j))
        rundp[0][i][j] = rundp[1][i][j] = 0LL;
    int z = 0;
    rundp[z][0][twos] = 1;
    for (int i = 0; i < ones; ++i) {
      int y = z ^ 1;
      for (int(j) = 0; (j) < (ones + 2); ++(j))
        for (int(k) = 0; (k) < (twos + 2); ++(k)) rundp[y][j][k] = 0;
      for (int j = 0; j <= ones; ++j) {
        for (int k = twos; k >= 0; --k) {
          rundp[y][j][k] = (rundp[y][j][k] + rundp[z][j][k]) % modu;
          if (k) {
            rundp[z][j][k - 1] =
                (rundp[z][j][k - 1] + ((rundp[z][j][k] * k) % modu)) % modu;
          }
          if (j) {
            rundp[y][j - 1][k] =
                (rundp[y][j - 1][k] + ((rundp[z][j][k] * j) % modu)) % modu;
          }
          rundp[y][j + 1][k] = (rundp[y][j + 1][k] + rundp[z][j][k]) % modu;
        }
      }
      z = y;
    }
    alias = 0;
    for (int i = 0; i <= twos; ++i) {
      alias += (Solv(0, i) * rundp[z][0][i]) % modu;
      alias %= modu;
    }
  }
  return alias;
}
int main() {
  int n;
  cin >> n;
  int ones = 0;
  int twos = 0;
  for (int(i) = 0; (i) < (515); ++(i))
    for (int(j) = 0; (j) < (515); ++(j)) memo[i][j] = -1;
  for (int(i) = 0; (i) < (n); ++(i)) {
    int x;
    scanf("%d", &x);
    if (x == 1)
      ++ones;
    else
      ++twos;
  }
  cout << Solv(ones, twos) << endl;
}
