#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 9, mod = 1e9 + 7;
int n, a, b;
int main() {
  cin >> n;
  for (int i = 0, v; i < n; i++) {
    cin >> v;
    if (v == 1)
      a++;
    else
      b++;
  }
  long long ans = 1;
  for (int i = a + 1; i <= n; i++) ans = (ans * i) % mod;
  long long mul, x = 1, y = 1;
  if (a < 2)
    mul = 1;
  else {
    for (int i = 2; i <= a; i++) {
      long long nx = (y + x * (i - 1)) % mod;
      x = y, y = nx;
    }
    mul = y;
  }
  cout << (ans * mul) % mod << endl;
  return 0;
}
