#include <bits/stdc++.h>
using namespace std;
const int Mod = 1000000007;
struct Int {
  int a;
  Int(int _a = 0) : a(_a) {}
  Int operator+(const Int& o) {
    Int ret(a + o.a);
    if (ret.a >= Mod) ret.a -= Mod;
    return ret;
  }
  Int operator*(const Int& o) {
    Int ret;
    ret.a = (long long)a * o.a % Mod;
    return ret;
  }
};
int main() {
  int n, a = 0, b = 0, x, i;
  scanf("%d", &n);
  for (i = 0; i < n; ++i) {
    scanf("%d", &x);
    if (x == 1)
      ++a;
    else
      ++b;
  }
  Int _f(1), f(1), t;
  for (i = 2; i <= a; ++i) {
    t = Int(i - 1) * _f + f;
    _f = f;
    f = t;
  }
  for (i = a + 1; i <= a + b; ++i) f = f * i;
  cout << f.a << endl;
  return 0;
}
