#include <bits/stdc++.h>
using namespace std;
const int p = 1000000007;
long long a[1000005];
int main() {
  long long n, s = 0;
  int i;
  scanf("%I64d", &n);
  for (i = 1; i <= n; i++) {
    long long x;
    scanf("%I64d", &x);
    if (x == 1) s++;
  }
  a[0] = 1;
  a[1] = 1;
  for (i = 2; i <= s; i++) a[i] = (a[i - 1] + a[i - 2] * (i - 1)) % p;
  for (i = s + 1; i <= n; i++) a[s] = a[s] * i % p;
  printf("%I64d\n", a[s]);
  return 0;
}
