#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000 * 1000 * 1000 + 7;
const int N = 1000 * 1000 + 10;
long long dp[N];
int main() {
  ios_base::sync_with_stdio(0);
  int n;
  cin >> n;
  int c1 = 0, c2 = 0;
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    if (x == 1)
      c1++;
    else
      c2++;
  }
  dp[0] = dp[1] = 1;
  for (int i = 2; i <= c1; i++)
    dp[i] = dp[i - 1] + dp[i - 2] * (i - 1), dp[i] %= MOD;
  long long res = dp[c1];
  for (int i = c1 + 1; i <= c1 + c2; i++) res *= i, res %= MOD;
  cout << res;
  return 0;
}
