#include <bits/stdc++.h>
using namespace std;
const int p = 1000000007, maxn = 1000011;
int mul(int a, int b) {
  int ans = 1;
  for (int i = a; i <= b; ++i) ans = 1LL * ans * i % p;
  return ans;
}
int f(int n) {
  static int I[maxn];
  I[0] = 1;
  I[1] = 1;
  I[2] = 2;
  for (int i = 3; i <= n; ++i) I[i] = (I[i - 1] + (i - 1LL) * I[i - 2]) % p;
  return I[n];
}
int n;
int main() {
  scanf("%d", &n);
  int s1 = 0;
  for (int i = 1, x; i <= n; ++i) {
    scanf("%d", &x);
    if (x == 1) ++s1;
  }
  printf("%d\n", 1LL * f(s1) * mul(s1 + 1, n) % p);
}
