#include <bits/stdc++.h>
using namespace std;
int dp[11][60000];
int P[11];
vector<int> a;
int r(int p, int mask, vector<int> a) {
  if (p + 1 == a.size()) return 1;
  if (dp[p][mask] != -1) return dp[p][mask];
  if (a[p] == 0) return dp[p][mask] = r(p + 1, mask, a);
  int res = r(p + 1, mask, a);
  for (int i = (p + 1); i < (a.size()); ++i) {
    if (a[i] > 0) {
      int nmask = 2;
      if (a[p] == 1) {
        nmask -= P[i] * a[i];
        a[i]--;
        nmask += P[i] * a[i];
        res += r(p + 1, nmask, a);
        a[i]++;
      } else
        res += r(p + 1, nmask, a);
    }
  }
  return dp[p][mask] = res;
}
int n;
int dp1[510][510];
int mod = 1000000007;
int r1(int p, int have) {
  if (p == n) return 1;
  if (dp1[p][have] != -1) return dp1[p][have];
  if (a[p] == 2) return dp1[p][have] = ((n - p) * 1ll * r1(p + 1, have)) % mod;
  int res = 0;
  if (have) {
    long long c = have * 1ll * r1(p + 1, have - 1);
    c %= mod;
    res += c;
    if (res >= mod) res -= mod;
  }
  res += r1(p + 1, have + 1);
  if (res >= mod) res -= mod;
  return dp1[p][have] = res;
}
int main() {
  scanf("%d", &n);
  a.resize(n);
  for (int i = (0); i < (n); ++i) {
    scanf("%d", &a[i]);
  }
  sort(a.rbegin(), a.rend());
  memset(dp1, -1, sizeof(dp1));
  cout << r1(0, 0) << endl;
  return 0;
}
