#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9 + 7;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  long long a = 0, b = 0;
  long long n;
  cin >> n;
  while (n--) {
    long long x;
    cin >> x;
    if (x == 1)
      a++;
    else
      b++;
  }
  long long x = 1, y = 1;
  for (long long i = 2; i <= a; i++) {
    long long temp = x;
    x = (x + (i - 1) * y) % MOD;
    y = temp;
  }
  for (long long i = a + 1; i <= a + b; i++) x = (x * i) % MOD;
  cout << x << "\n";
  return 0;
}
