#include <bits/stdc++.h>
const int mod = 1e9 + 7;
const int N = 1000010;
const int inf = 0x3f3f3f3f;
using namespace std;
int n;
long long p[N], a[N];
int main() {
  long long sum1 = 0, sum2 = 0;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    int a;
    scanf("%d", &a);
    if (a == 1)
      sum1++;
    else
      sum2++;
  }
  long long ret = 1;
  a[0] = 1;
  a[1] = 1;
  for (int i = 2; i <= n; i++)
    a[i] = a[i - 1] + (i - 1) * a[i - 2], a[i] %= mod;
  ret = a[sum1];
  for (int i = n; i > sum1; i--) ret = ret * i % mod;
  cout << ret << endl;
  return 0;
}
