#include <bits/stdc++.h>
const long long mod = 1000000007;
int main() {
  int n, t = 0, a;
  assert(scanf("%d", &n) == 1);
  for (int i = 0; i < n; i++) {
    assert(scanf("%d", &a) == 1);
    if (a == 2) t++;
  }
  long long r = 1;
  while (t > 0) {
    r = (r * n) % mod;
    n--, t--;
  }
  long long F[n + 1];
  F[0] = F[1] = 1;
  for (int i = 2; i <= n; i++) {
    F[i] = F[i - 1] + (i - 1) * F[i - 2];
    F[i] %= mod;
  }
  long long ans = (r * F[n]) % mod;
  printf("%d\n", (int)ans);
  return 0;
}
