#include <bits/stdc++.h>
using namespace std;
template <typename T>
inline T Abs(T a) {
  return a > 0 ? a : -a;
}
template <typename T>
inline T sqr(T a) {
  return a * a;
}
template <typename T>
inline void relaxMin(T &a, T b) {
  if (b < a) a = b;
}
template <typename T>
inline void relaxMax(T &a, T b) {
  if (b > a) a = b;
}
const int INF = (int)1E9;
const long double EPS = 1E-6;
const long double PI = 3.1415926535897932384626433832795;
int dp[2000][2000];
int mod = 1000000007;
void solve() {
  int n;
  cin >> n;
  int k;
  int x = 0, y = 0;
  for (int i(0), _bb(n); i < _bb; ++i) {
    cin >> k;
    if (k == 1)
      x++;
    else
      y++;
  }
  int a1 = 0, a2 = 1;
  for (int i(0), _bb(x); i < _bb; ++i) {
    int v = (a2 + i * 1LL * a1) % mod;
    a1 = a2;
    a2 = v;
  }
  int ans = a2;
  for (int j(0), _bb(y); j < _bb; ++j) {
    ans = (ans * 1LL * (x + 1 + j)) % mod;
  }
  cout << ans << endl;
}
int main() {
  srand(0xA1B2C3D4);
  solve();
  return 0;
}
