#include <bits/stdc++.h>
using namespace std;
long long d[1000000];
long long mod = 1000000007;
int main(void) {
  int n;
  scanf("%d", &n);
  d[0] = 1;
  d[1] = 1;
  for (int i = 2; i <= n; i++) {
    d[i] = (d[i - 1] + d[i - 2] * (i - 1)) % mod;
  }
  int x[2] = {0, 0};
  for (int i = 0; i < n; i++) {
    int t;
    scanf("%d", &t);
    x[t - 1]++;
  }
  long long res = d[x[0]];
  for (int i = 0; i < x[1]; i++) {
    res = (res * (n - i)) % mod;
  }
  printf("%d\n", (int)res);
  return 0;
}
