#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:256000000")
using namespace std;
const long long mod = 1000000007;
long long d[100005];
int a[100005];
int n;
int main() {
  cin >> n;
  int cnt1 = 0, cnt2 = 0;
  for (int i = 0; i < int(n); i++) {
    scanf("%d", &a[i]);
    if (a[i] == 1) cnt1++;
    if (a[i] == 2) cnt2++;
  }
  d[0] = 1;
  d[1] = 1;
  for (int i = 2; i <= cnt1; i++) {
    d[i] = (d[i - 1] + d[i - 2] * (i - 1)) % mod;
  }
  long long ans = d[cnt1];
  for (int i = 0; i < int(cnt2); i++) {
    ans = (ans * (cnt1 + i + 1)) % mod;
  }
  cout << ans << endl;
  return 0;
}
