#include <bits/stdc++.h>
using namespace std;
int br0 = 0;
int br1 = 0;
long long dp[(1 << 20)];
int main() {
  int i;
  int n;
  int x;
  long long ans = 0;
  scanf("%d", &n);
  for (i = 0; i < n; i++) {
    scanf("%d", &x);
    if (x == 1)
      br0++;
    else
      br1++;
  }
  dp[1] = 1;
  dp[2] = 2;
  dp[3] = 4;
  for (i = 4; i <= n; i++) {
    dp[i] = (dp[i - 1] + ((i - 1) * dp[i - 2]) % 1000000007) % 1000000007;
  }
  if (br0 == 0) {
    ans = 1;
    for (i = 1; i <= n; i++) {
      ans = ((ans % 1000000007) * (i % 1000000007)) % 1000000007;
    }
    printf("%I64d\n", ans);
    return 0;
  }
  if (br1 == 0) {
    printf("%I64d\n", dp[n]);
    return 0;
  }
  ans = dp[br0];
  br0++;
  for (i = 1; i <= br1; i++) {
    ans = ((ans % 1000000007) * (br0 % 1000000007)) % 1000000007;
    br0++;
  }
  printf("%I64d\n", ans);
  return 0;
}
