#include <bits/stdc++.h>
using namespace std;
const long long ff = 1e6 + 1;
const long long inf = 1e18 + 1;
const long long M = 1e9 + 7;
long long n, a[ff], f[ff];
void init() {
  cin >> n;
  long long s1 = 0, s2 = 0, haha = 1;
  for (long long i = 1; i <= n; ++i)
    scanf("%lld", &a[i]), s1 += (a[i] == 1), s2 += (a[i] == 2);
  f[0] = 1;
  for (long long i = 1; i <= s1; ++i)
    f[i] = (f[i - 2] * (i - 1) + f[i - 1]) % M;
  for (long long j = n; j >= n - s2 + 1; --j) haha = haha * j % M;
  cout << f[s1] * haha % M << "\n";
}
signed main() {
  long long Ts = 1;
  while (Ts--) init();
}
