#include <bits/stdc++.h>
using namespace std;
inline long long read() {
  long long s = 0, w = 1, ch = getchar();
  while (!isdigit(ch)) {
    if (ch == '-') w = -1;
    ch = getchar();
  }
  while (isdigit(ch)) {
    s = (s << 3) + (s << 1) + ch - 48;
    ch = getchar();
  }
  return s * w;
}
const long long maxn = 1e6 + 50, mod = 1e9 + 7;
long long n, a[maxn], f[maxn];
long long A;
signed main() {
  cin >> n;
  for (long long i = 1; i <= n; i++) {
    a[i] = read();
    if (a[i] == 1) A++;
  }
  f[1] = 1;
  f[2] = 2;
  f[0] = 1;
  for (long long i = 3; i <= n; i++)
    f[i] = f[i - 2] * (i - 1) % mod + f[i - 1], f[i] %= mod;
  long long ans = f[A];
  for (long long i = A + 1; i <= n; i++) ans = ans * i % mod;
  cout << ans << endl;
  return 0;
}
