#include <bits/stdc++.h>
using namespace std;
long long p = 1000000007;
long long f[1000010], g[1000010];
long long inv(long long a) {
  long long r = 1;
  for (long long t = p - 2; t; t >>= 1) {
    if (t & 1) r = r * a % p;
    a = a * a % p;
  }
  return r;
}
int main() {
  f[0] = f[1] = 1;
  for (int i = 2; i <= 1000000; ++i) f[i] = (f[i - 1] + f[i - 2] * (i - 1)) % p;
  g[0] = 1;
  for (int i = 1; i <= 1000000; ++i) g[i] = g[i - 1] * i % p;
  long long n = 0, m = 0;
  int k;
  scanf("%d", &k);
  for (int i = 1; i <= k; ++i) {
    int t;
    scanf("%d", &t);
    if (t == 1)
      ++n;
    else
      ++m;
  }
  long long t1 = g[n + m] * inv(g[n]) % p;
  long long t2 = t1 * f[n] % p;
  printf("%d\n", int(t2));
  return 0;
}
