#include <bits/stdc++.h>
const int MOD = 1000000000 + 7;
inline void readInt(int& a) {
  a = 0;
  int c;
  do c = getchar();
  while (c < '0' || c > '9');
  do {
    a = a * 10 - '0' + c;
    c = getchar();
  } while (c >= '0' && c <= '9');
}
int n, cnta, cntb;
int main() {
  readInt(n);
  for (int i = 0; i < n; i++) {
    int v;
    readInt(v);
    if (v == 1)
      ++cnta;
    else
      ++cntb;
  }
  int p = 1, c = 1;
  for (int i = 1; i <= cnta; i++) {
    int nn = (int)((long long)p * (i - 1) % MOD) + c;
    if (nn >= MOD) nn -= MOD;
    p = c;
    c = nn;
  }
  for (int i = 1; i <= cntb; i++) c = (int)((long long)c * (i + cnta) % MOD);
  printf("%d\n", c);
  return 0;
}
