#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
long long fuck[1000010], a[1000010];
void work() {
  int i;
  fuck[0] = 1;
  fuck[1] = 1;
  fuck[2] = 2;
  for (i = 3; i <= 1000000; i++)
    fuck[i] = (fuck[i - 1] + ((i - 1) * fuck[i - 2]) % mod) % mod;
}
int main() {
  int n, i, sum = 0;
  scanf("%d", &n);
  work();
  for (i = 1; i <= n; i++) {
    scanf("%I64d", &a[i]);
    if (a[i] == 1) sum++;
  }
  long long ans = fuck[sum];
  for (i = sum + 1; i <= n; i++) {
    ans = (ans * i) % mod;
  }
  printf("%I64d\n", ans);
  return 0;
}
