#include <bits/stdc++.h>
using namespace std;
int a[1000005];
long long dp[1000005];
int main() {
  dp[0] = dp[1] = 1;
  for (int i = 2; i <= 1000000; ++i)
    dp[i] = (dp[i - 1] + (i - 1LL) * dp[i - 2]) % 1000000007;
  int n, cnt = 0;
  cin >> n;
  for (int i = 1; i <= n; ++i) scanf("%d", a + i);
  for (int i = 1; i <= n; ++i)
    if (a[i] == 1) ++cnt;
  long long ans = dp[cnt];
  cnt = n - cnt;
  int k = n;
  for (int i = 1; i <= cnt; ++i, --k) ans = ans * k % 1000000007;
  cout << ans << endl;
  return 0;
}
