#include <bits/stdc++.h>
using namespace std;
const int N = 1050000;
const int MOD = 1000000007;
int s;
int n = 0, m = 0;
int xu[N];
bool notprime[N];
int prime[N], last[N], cc[N];
int jia(int x, int y) {
  x += y;
  if (x >= MOD) x -= MOD;
  return x;
}
int cheng(int x, int y) {
  long long res = x;
  res *= y;
  res %= MOD;
  int resx = res;
  return resx;
}
void add(int x) {
  while (x != 1) {
    cc[last[x]]++;
    x /= last[x];
  }
}
void del(int x) {
  while (x != 1) {
    cc[last[x]]--;
    x /= last[x];
  }
}
void Init(int x) {
  int i, j;
  for (i = 2; i <= x; i++) {
    if (!notprime[i]) {
      prime[++prime[0]] = i;
      last[i] = i;
    }
    for (j = 1; j <= prime[0]; j++) {
      if (i * prime[j] > x) break;
      notprime[i * prime[j]] = 1;
      last[i * prime[j]] = prime[j];
      if (i % prime[j] == 0) break;
    }
  }
}
int zuhe(int x, int y) {
  Init(x + y);
  int i;
  for (i = x + y; i > y; i--) add(i);
  for (i = 1; i <= x; i++) del(i);
  int res = 1;
  for (i = 1; i <= prime[0]; i++) {
    while (cc[prime[i]]--) res = cheng(res, prime[i]);
  }
  return res;
}
int main() {
  int i;
  int now;
  scanf("%d", &s);
  while (s--) {
    scanf("%d", &now);
    if (now == 2)
      n++;
    else
      m++;
  }
  int ans = zuhe(n, m);
  for (i = 1; i <= n; i++) ans = cheng(ans, i);
  xu[0] = xu[1] = 1;
  for (i = 2; i <= m; i++) xu[i] = jia(xu[i - 1], cheng(i - 1, xu[i - 2]));
  ans = cheng(ans, xu[m]);
  printf("%d\n", ans);
  return 0;
}
