#include <bits/stdc++.h>
using namespace std;
const int inf = 1e9;
const double eps = 1e-9;
const double INF = inf;
const double EPS = eps;
long long tmpl, res, D[600][600];
int Cnt[2], n;
int main() {
  int i, j, tmp;
  scanf("%d", &n);
  for (i = 0; i < n; i++) scanf("%d", &tmp), Cnt[tmp - 1]++;
  for (D[0][0] = 1, i = 0; i < Cnt[0]; i++) {
    for (j = 0; j <= i; j++) D[i + 1][j + 1] = D[i][j];
    if (i == 0) continue;
    for (j = 0; j <= i; j++)
      D[i + 1][j] += D[i - 1][j] * i, D[i + 1][j] %= (1000000007);
  }
  for (i = 0; i <= Cnt[0]; i++) res += D[Cnt[0]][i], res %= (1000000007);
  for (i = 0; i < Cnt[1]; i++) res *= n - i, res %= (1000000007);
  cout << res << endl;
  ;
  return 0;
}
