#include <bits/stdc++.h>
using namespace std;
int dp[1000005];
int I(int n) {
  if (n == 1 || n == 0) return 1;
  if (~dp[n]) return dp[n];
  long long res =
      ((long long)I(n - 1) + (long long)(n - 1) * I(n - 2)) % 1000000007;
  return dp[n] = res;
}
int getRes(int n, int m) {
  long long r = 1, i;
  for (i = n + 1; i <= n + m; i++) r = (r * i) % 1000000007;
  long long res = (r * I(n)) % 1000000007;
  return res;
}
int main() {
  int i, c, n, m, num;
  memset((dp), (-1), sizeof(dp));
  n = m = 0;
  scanf("%d", &c);
  for (i = 0; i < c; i++) {
    scanf("%d", &num);
    n += (num == 1);
    m += (num == 2);
  }
  cout << getRes(n, m) << endl;
  return 0;
}
