#include <bits/stdc++.h>
using namespace std;
static const int INF = 500000000;
template <class T>
void debug(T a, T b) {
  for (; a != b; ++a) cerr << *a << ' ';
  cerr << endl;
}
int n;
int one, two;
long long int base[1000005];
const long long int mod = 1000000007;
int main() {
  int n;
  scanf("%d", &n);
  int one = 0, two = 0;
  for (int i = 0; i < n; ++i) {
    int t;
    scanf("%d", &t);
    if (t == 1)
      ++one;
    else
      ++two;
  }
  base[0] = base[1] = 1;
  for (int i = 2; i <= one; ++i) {
    base[i] = base[i - 1] + base[i - 2] * (i - 1);
    base[i] %= mod;
  }
  long long int res = base[one];
  for (int i = 0; i < two; ++i) {
    res *= one + 1 + i;
    res %= mod;
  }
  cout << res << endl;
  return 0;
}
