#include <bits/stdc++.h>
using namespace std;
inline void read(int& x) {
  static char c;
  while (!isdigit(c = getchar()))
    ;
  x = c ^ 48;
  while (isdigit(c = getchar())) x = (x * 10) + (c ^ 48);
}
const int Mod = 1000000007, N = 5000005;
int T, n, tmp;
int Pow(int a, int b) {
  int ans = 1;
  while (b) {
    if (b & 1) ans = 1ll * ans * a % Mod;
    a = 1ll * a * a % Mod, b >>= 1;
  }
  return ans;
}
int Fac[N], Iac[N], _2Pow[N];
inline void Init() {
  int Inv = Pow(2, Mod - 2);
  Fac[0] = Iac[0] = _2Pow[0] = 1;
  for (register int i = 1; i <= N - 4; ++i)
    Fac[i] = 1ll * Fac[i - 1] * i % Mod,
    _2Pow[i] = 1ll * Inv * _2Pow[i - 1] % Mod;
  Iac[N - 4] = Pow(Fac[N - 4], Mod - 2);
  for (register int i = N - 5; i; --i)
    Iac[i] = 1ll * Iac[i + 1] * (i + 1) % Mod;
}
inline int Binom(int n, int m) {
  return 1ll * Fac[n] * Iac[m] % Mod * Iac[n - m] % Mod;
}
int Ans, t;
inline void Work() {
  Init();
  T = 1;
  while (T--) {
    t = Ans = 0;
    read(n);
    for (register int i = 1; i <= n; ++i) read(tmp), t += tmp == 1;
    for (register int i = (t - 1) / 2 + 1; i <= t; ++i)
      Ans = (Ans + 1ll * Fac[t] * Iac[2 * i - t] % Mod * _2Pow[t - i] % Mod *
                       Iac[t - i] % Mod) %
            Mod;
    if (!t) ++Ans;
    Ans = 1ll * Ans * Fac[n] % Mod * Iac[t] % Mod;
    printf("%d\n", Ans);
  }
}
int main() { Work(); }
