#include <bits/stdc++.h>
const double pi = acos(-1.0), eps = 1e-9;
const int dx[8] = {1, -1, 0, 0, 1, 1, -1, -1};
const int dy[8] = {0, 0, 1, -1, 1, -1, -1, 1};
const int MO = (int)(1e9 + 7);
using namespace std;
long long f[1000010];
int ans = 1, num[2], n;
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    int x;
    scanf("%d", &x);
    ++num[x - 1];
  }
  for (int i = 0; i < num[1]; i++) ans = (long long)ans * (n - i) % MO;
  f[0] = f[1] = 1;
  int sum = 0;
  for (int i = 2; i <= num[0]; i++) {
    f[i] = ((long long)f[i - 2] * (i - 1) + sum + 1) % MO;
    sum = ((long long)f[i - 2] * (i - 1) + sum) % MO;
  }
  ans = (long long)ans * f[num[0]] % MO;
  cout << ans << endl;
}
