#include <bits/stdc++.h>
using namespace std;
const int OO = 1e9;
const long long MOD = 1e9 + 7;
inline long long addmod(long long a, long long b) { return (a + b) % MOD; }
inline long long submod(long long a, long long b) {
  return (MOD + a - b) % MOD;
}
inline long long mulmod(long long a, long long b) { return (a * b) % MOD; }
inline long long expmod(long long a, long long e) {
  long long ret = 1;
  while (e) {
    if (e & 1) ret = mulmod(ret, a);
    a = mulmod(a, a);
    e >>= 1;
  }
  return ret;
}
inline long long divmod(long long a, long long b) {
  return mulmod(a, expmod(b, MOD - 2));
}
const int N = 1e6 + 5;
int fac[N];
inline void prec_fac() {
  fac[0] = 1;
  fac[1] = 1;
  for (int i = 2; i <= N - 5; i += 1) fac[i] = mulmod(fac[i - 1], i);
}
inline long long C2(long long a) { return divmod(mulmod(a, submod(a, 1)), 2); }
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  prec_fac();
  int n;
  cin >> n;
  int a = 0, b = 0;
  for (int i = 1; i <= n; i += 1) {
    int x;
    cin >> x;
    if (x == 1)
      a++;
    else
      b++;
  }
  if (n == 1) {
    cout << 1 << '\n';
    return 0;
  }
  long long awesome_multiplier = 1;
  long long normal_multiplier = 1;
  int left = a, k = 1;
  while (left >= 2) {
    normal_multiplier = mulmod(normal_multiplier, C2(left));
    awesome_multiplier =
        addmod(awesome_multiplier, divmod(normal_multiplier, fac[k]));
    left -= 2;
    k++;
  }
  cout << mulmod(divmod(fac[n], fac[a]), awesome_multiplier) << '\n';
  return 0;
}
