#include <bits/stdc++.h>
using namespace std;
int n, fact[1000010], invfact[1000010];
int s1, s2;
int Power(int p, int n) {
  int ans = 1;
  for (; n; n >>= 1, p = (long long)p * p % 1000000007)
    if (n & 1) ans = (long long)ans * p % 1000000007;
  return ans;
}
int inv(int p) { return Power(p, 1000000007 - 2); }
int C(int n, int m) {
  return (long long)fact[n] * invfact[m] % 1000000007 * invfact[n - m] %
         1000000007;
}
void read() {
  scanf("%d", &n);
  fact[0] = invfact[0] = 1;
  for (int i = 1; i <= n + 1; ++i)
    fact[i] = (long long)fact[i - 1] * i % 1000000007;
  invfact[n + 1] = inv(fact[n + 1]);
  for (int i = n; i >= 1; --i)
    invfact[i] = (long long)invfact[i + 1] * (i + 1) % 1000000007;
  for (int i = 1, x; i <= n; ++i) {
    scanf("%d", &x);
    if (x == 1)
      ++s1;
    else
      ++s2;
  }
}
int work() {
  static int power[1000010];
  power[0] = 1, power[1] = (1000000007 + 1) / 2;
  for (int i = 2; i <= n; ++i)
    power[i] = (long long)power[i - 1] * power[1] % 1000000007;
  int ans = 0;
  long long f2 = (long long)fact[n] * invfact[s1] % 1000000007;
  for (int i = 0; i <= s1; ++i)
    if ((s1 - i) % 2 == 0) {
      int m = i + (s1 - i) / 2;
      int f1 = (long long)C(s1, i) * C(s1 - i, (s1 - i) / 2) % 1000000007 *
               fact[(s1 - i) / 2] % 1000000007 * power[(s1 - i) / 2] %
               1000000007;
      ans = (ans + (long long)f1 * f2) % 1000000007;
    }
  return ans;
}
int main() {
  read();
  printf("%d\n", work());
  return 0;
}
