#include <bits/stdc++.h>
using namespace std;
const long long N = 1e6 + 5;
const long long mod = 1e9 + 7;
long long n, sum1, sum2, f[N];
signed main() {
  cin >> n;
  for (long long i = 1; i <= n; i++) {
    long long x;
    cin >> x;
    if (x == 1)
      sum1++;
    else
      sum2++;
  }
  f[0] = f[1] = 1;
  for (long long i = 2; i <= sum1; i++)
    f[i] = (f[i - 1] + f[i - 2] * (i - 1) % mod) % mod;
  long long sum = 1;
  for (long long i = 1; i <= sum2; i++) sum = sum * (n - i + 1) % mod;
  cout << sum * f[sum1] % mod;
  return 0;
}
