#include <bits/stdc++.h>
using namespace std;
const int modul = 1e9 + 7;
long long f[2] = {1, 1};
int n;
long long kq;
int main() {
  ios_base::sync_with_stdio(false);
  cin >> n;
  int dem(0);
  int x;
  for (int i = 0; i < n; ++i) {
    cin >> x;
    if (x == 1) dem++;
  }
  for (int i = 1; i < dem; ++i) {
    if (i % 2) {
      f[0] = (f[1] + i * f[0]) % modul;
    } else {
      f[1] = (f[0] + i * f[1]) % modul;
    }
  }
  kq = f[dem % 2];
  for (int i = dem + 1; i <= n; ++i) {
    kq = (kq * i) % modul;
  }
  cout << kq << endl;
  return 0;
}
