#include <bits/stdc++.h>
using namespace std;
long long max(long long a, long long b) {
  if (a > b) {
    return a;
  } else {
    return b;
  }
}
long long min(long long a, long long b) {
  if (a < b) {
    return a;
  } else {
    return b;
  }
}
int ans = 0;
int n, a[1000001];
int main() {
  cin >> n;
  int c2 = 0;
  for (long long i = 1; i <= n; i++) {
    cin >> a[i];
    if (a[i] == 2) {
      c2++;
    }
  }
  int c1 = n - c2;
  long long f[n + 1];
  f[0] = 1;
  f[1] = 1;
  for (long long i = 2; i <= n; i++) {
    f[i] = (f[i - 1] + (f[i - 2] * (i - 1))) % 1000000007;
    ;
  }
  long long ans = 1;
  for (long long i = 1; i <= c2; i++) {
    ans = ((long long)ans * (i + c1)) % 1000000007;
    ;
  }
  ans = (ans * f[c1]) % 1000000007;
  ;
  cout << ans << endl;
  return 0;
}
