#include <bits/stdc++.h>
using namespace std;
const int MOD = (int)1e9 + 7;
int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (auto &ai : a) cin >> ai;
  int one = count(begin(a), end(a), 1), two = count(begin(a), end(a), 2);
  vector<long long> dp(one + 1);
  dp[0] = 1;
  for (int i = 1; i <= one; i++) {
    dp[i] += dp[i - 1];
    if (i >= 2) dp[i] += dp[i - 2] * (i - 1) % MOD;
    dp[i] %= MOD;
  }
  long long ans = dp[one];
  for (int i = 1; i <= two; i++) ans = ans * (one + i) % MOD;
  cout << ans << endl;
  return 0;
}
