#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
const int N = 1919810;
int n, t, a[N], s[114];
long long f[N], fac[N], kkr;
int main() {
  fac[0] = 1;
  f[0] = f[1] = 1;
  for (int i = 1; i <= 1919800; i++) fac[i] = fac[i - 1] * i % mod;
  for (int i = 2; i <= 1919800; i++)
    f[i] = (f[i - 1] + (i - 1) * f[i - 2]) % mod;
  scanf("%d", &n);
  s[1] = s[2] = 0;
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]), s[a[i]]++;
  kkr = f[s[1]];
  for (int i = 1; i <= s[2]; i++) kkr = kkr * (s[1] + i) % mod;
  printf("%lld\n", kkr);
}
