#include <bits/stdc++.h>
using namespace std;
const int P = 1e9 + 7;
int n, f[1000005];
int main() {
  cin >> n;
  f[0] = f[1] = 1;
  int t, cnt = 0;
  for (int i = (1); i <= (n); i++) scanf("%d", &t), cnt += 2 - t;
  for (int i = (1); i <= (cnt); i++) f[i + 1] = (f[i] + 1LL * i * f[i - 1]) % P;
  for (int i = (cnt + 1); i <= (n); i++) f[cnt] = 1LL * f[cnt] * i % P;
  cout << f[cnt];
  return 0;
}
