#include <bits/stdc++.h>
using namespace std;
long long fact(long long a) {
  long long ans = 1;
  for (int i = 1; i < a + 1; i++) {
    ans *= i;
    ans %= 1000000007;
  }
  return ans;
}
long long cuni(long long a) {
  if (a < 2) return 1;
  long long b0, b1;
  b0 = b1 = 1;
  for (int i = 1; i < a; i++) {
    long long aux = b1 + b0 * i;
    aux %= 1000000007;
    b0 = b1;
    b1 = aux;
  }
  return b1;
}
int main() {
  int n;
  cin >> n;
  long long u = 0;
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    if (x == 1) u++;
  }
  long long uni = cuni(u);
  for (int i = u + 1; i < n + 1; i++) {
    uni *= i;
    uni %= 1000000007;
  }
  cout << uni << endl;
}
