#include <bits/stdc++.h>
using namespace std;
long long dp[1000010];
int mod = 1000000007;
int main() {
  int n, i, j, k;
  cin >> n;
  int a = 0, b = 0;
  while (n--) {
    scanf("%d", &i);
    if (i == 1)
      a++;
    else
      b++;
  }
  for (i = 2, dp[1] = dp[0] = 1; i <= a; i++)
    dp[i] = (dp[i - 1] + dp[i - 2] * (i - 1)) % mod;
  long long ans = dp[a];
  while (b--) ans *= a + 1, ans %= mod, a++;
  cout << ans << endl;
}
