#include <bits/stdc++.h>
using namespace std;
int Fac[1000010], IFac[1000010];
void gcd2(long long a, long long b, long long &x, long long &y) {
  if (b == 0) {
    x = 1, y = 0;
    return;
  }
  gcd2(b, a % b, x, y);
  long long t = x;
  x = y, y = t - a / b * y;
}
int Inv(int n) {
  long long x, y;
  gcd2(n, 1000000007, x, y);
  if (x < 0)
    return x + 1000000007;
  else
    return x;
}
const int Inv2 = Inv(2);
int n, m;
int main() {
  Fac[0] = IFac[0] = 1;
  for (int i = 1; i < 1000010; i++)
    Fac[i] = (long long)Fac[i - 1] * i % 1000000007;
  IFac[1000010 - 1] = Inv(Fac[1000010 - 1]);
  for (int i = 1000010 - 2; i >= 0; i--)
    IFac[i] = (long long)IFac[i + 1] * (i + 1) % 1000000007;
  int _;
  scanf("%d", &_);
  while (_--) {
    int x;
    scanf("%d", &x);
    if (x == 1)
      n++;
    else
      m++;
  }
  int n1 = n;
  int S = 1;
  for (int i = 1, s = 1; i <= n / 2; i++) {
    s = ((long long)s * ((long long)n1 * (n1 - 1) / 2 % 1000000007)) %
        1000000007;
    S = (S + (long long)s * IFac[i] % 1000000007) % 1000000007;
    n1 -= 2;
  }
  for (int i = 0; i < m; i++) S = (long long)S * (n + i + 1) % 1000000007;
  printf("%d\n", S);
  return 0;
}
