#include <bits/stdc++.h>
using namespace std;
const long long MOD = int(1e+9) + 7;
int N;
long long P[1000010];
int main() {
  scanf("%d", &N);
  int C[3];
  C[1] = C[2] = 0;
  int i;
  for (i = 1; i <= N; i++) {
    int u;
    scanf("%d", &u);
    C[u]++;
  }
  P[0] = P[1] = 1;
  for (i = 2; i <= C[1]; i++) P[i] = (P[i - 1] + (i - 1) * P[i - 2]) % MOD;
  long long ans = P[C[1]];
  for (i = 1; i <= C[2]; i++) ans = ans * (C[1] + i) % MOD;
  cout << ans << endl;
}
