#include <bits/stdc++.h>
using namespace std;
int getint() {
  int x = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || '9' < ch) {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while ('0' <= ch && ch <= '9') {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return f * x;
}
long long f[1123456];
int main() {
  int n = getint();
  f[0] = f[1] = 1;
  for (int i = 2; i <= n; i++)
    f[i] = (f[i - 1] + f[i - 2] * (i - 1)) % 1000000007;
  int a = 0, b = 0;
  for (int i = 1; i <= n; i++) {
    int x = getint();
    if (x == 1)
      a++;
    else
      b++;
  }
  long long ans = f[a];
  for (int i = 0; i < b; i++) ans = ans * (n - i) % 1000000007;
  cout << ans << endl;
}
