#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e6 + 10;
const int mod = 1e9 + 7;
int n;
int cnt[maxn];
int main() {
  scanf("%d", &n);
  int a = 0, b = 0;
  for (int i = 0; i < n; i++) {
    scanf("%d", &cnt[i]);
    if (cnt[i] == 1)
      ++a;
    else
      ++b;
  }
  vector<int> dp(a + b + 1, 0);
  dp[0] = dp[1] = 1;
  for (int i = 2; i <= a + b; i++)
    dp[i] = (dp[i - 1] + ((long long)(i - 1) * dp[i - 2]) % mod) % mod;
  int ans = 1;
  for (int i = a + 1; i <= a + b; i++) ans = ((long long)ans * i) % mod;
  ans = ((long long)ans * dp[a]) % mod;
  printf("%d\n", ans);
  return 0;
}
