#include <bits/stdc++.h>
using namespace std;
const int SIZE = 1000006;
const int md = 1e9 + 7;
int N;
long long ball[SIZE][2];
void init() {
  ball[0][0] = 1;
  ball[1][0] = 1;
  ball[1][1] = 1;
  for (int i = 1; i <= 1000000; i++) {
    ball[i + 1][1] = ball[i][0] % md * (i + 1) % md;
    ball[i + 1][1] %= md;
    ball[i + 1][0] = ball[i][0] % md + ball[i][1] % md;
    ball[i + 1][0] %= md;
  }
}
int main() {
  init();
  int a;
  cin >> a;
  int count1 = 0;
  int count2 = 0;
  for (int i = 0; i < a; i++) {
    int x;
    cin >> x;
    if (x == 1)
      count1++;
    else
      count2++;
  }
  long long ans = ball[count1][0];
  for (int i = count1 + 1; i <= a; i++) {
    ans *= i;
    ans %= md;
  }
  cout << ans;
  return 0;
}
