#include <bits/stdc++.h>
using namespace std;
void _fill_int(int* p, int val, int rep) {
  int i;
  for (i = 0; i < rep; i++) p[i] = val;
}
int GETi() {
  int i;
  scanf("%d", &i);
  return i;
}
template <class T>
T sqr(T val) {
  return val * val;
}
int N, P[3];
signed long long mo = 1000000007;
signed long long I[1000001];
void solve() {
  int f, r, i, j, k, l, x, y;
  cin >> N;
  for (i = 0; i < N; i++) P[GETi()]++;
  I[0] = I[1] = 1;
  for (i = 2; i <= 1000000; i++) I[i] = (I[i - 1] + (i - 1) * I[i - 2]) % mo;
  signed long long ret = I[P[1]];
  for (i = P[1] + 1; i <= P[1] + P[2]; i++) ret = (ret * i) % mo;
  cout << ret << endl;
  return;
}
int main(int argc, char** argv) {
  if (argc > 1) freopen(argv[1], "r", stdin);
  solve();
  return 0;
}
