#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vl = vector<long long>;
using pii = pair<int, int>;
using vpii = vector<pair<int, int>>;
template <class T>
inline bool ckmin(T& a, T b) {
  return b < a ? a = b, 1 : 0;
}
template <class T>
inline bool ckmax(T& a, T b) {
  return b > a ? a = b, 1 : 0;
}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const char nl = '\n';
const int mxN = 1e6 + 10;
const int MOD = 1e9 + 7;
const long long infLL = 1e18;
int first[mxN];
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  int c1 = 0, c2 = 0;
  for (int i = (0); i < (n); i++) {
    int tmp;
    cin >> tmp;
    c1 += tmp == 1;
    c2 += tmp == 2;
  }
  first[0] = 1;
  for (int i = (1); i < (c1 + 1); i++)
    first[i] = (first[i - 1] + (ll)first[i - 2] * (i - 1)) % MOD;
  int ans = first[c1];
  for (int i = (1); i < (c2 + 1); i++) ans = (ll)ans * (c1 + i) % MOD;
  cout << ans << nl;
  return 0;
}
