#include <bits/stdc++.h>
using namespace std;
const int MOD = 1000000007;
int n, c1, c2;
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) {
    int x;
    cin >> x;
    ++(x == 1 ? c1 : c2);
  }
  long long p = 1, q = 1, res = 1;
  for (int i = 1; i <= c1; ++i) {
    long long t = (q + p) % MOD;
    res = q;
    p = q * (i + 1) % MOD;
    q = t;
  }
  for (int i = 1; i <= c2; ++i) {
    res = res * (c1 + i) % MOD;
  }
  cout << res << endl;
  return 0;
}
