#include <bits/stdc++.h>
using namespace std;
int n, a, b, in;
int I[100000 + 1];
void input() {
  scanf("%d", &n);
  a = 0, b = 0;
  for (long long i = 0; i < n; i++) {
    scanf("%d", &in);
    if (in == 1)
      a++;
    else
      b++;
  }
  I[0] = 1, I[1] = 1;
  for (int i = 2; i <= 100000; i++)
    I[i] = (I[i - 1] + (((long long)(i - 1)) * I[i - 2]) % 1000000007) %
           1000000007;
}
int main() {
  input();
  int out = I[a];
  for (int i = a + b; i > a; i--) out = (((long long)out) * i) % 1000000007;
  cout << out << endl;
  return 0;
}
