#include <bits/stdc++.h>
const long long mod = (long long)1e9 + 7;
long long f[1000010];
int n, c;
void process(void) {
  scanf("%d", &n);
  int i, t;
  for (i = 1; i <= n; i = i + 1) {
    scanf("%d", &t);
    if (t == 1) c++;
  }
  f[0] = 1LL;
  f[1] = 1LL;
  for (i = 2; i <= c; i = i + 1) f[i] = (f[i - 1] + f[i - 2] * (i - 1)) % mod;
  long long res = f[c];
  for (i = c + 1; i <= n; i = i + 1) res = (res * i) % mod;
  printf("%I64d", res);
}
int main(void) {
  process();
  return 0;
}
