#include <bits/stdc++.h>
using namespace std;
const int MOD = 1000000007;
long long dp[1000005];
long long add(long long a, long long b) { return (a + b) % MOD; }
long long mul(long long a, long long b) { return (a * b) % MOD; }
int main() {
  int n, one = 0, two = 0;
  cin >> n;
  for (int i = 0; i < n; i++) {
    int k;
    cin >> k;
    if (k == 1)
      one++;
    else
      two++;
  }
  dp[0] = dp[1] = 1LL;
  for (int i = 2; i <= one; i++) {
    dp[i] = add(dp[i - 1], mul(dp[i - 2], (i - 1)));
  }
  long long ans = dp[one];
  for (int i = 1; i <= two; i++) ans = mul(ans, one + i);
  cout << ans << endl;
  return 0;
}
