#include <bits/stdc++.h>
using namespace std;
int INP, AM, REACHEOF;
char BUF[(1 << 12) + 1], *inp = BUF;
const long double PI = acos((long double)-1.0);
const long long MOD = 1000000007LL;
long long f[1000111];
int main() {
  f[0] = 1;
  f[1] = 1;
  for (int n = (2), _b = (1000000); n <= _b; n++)
    f[n] = ((n - 1) * f[n - 2] + f[n - 1]) % MOD;
  int n;
  while (scanf("%d", &n) == 1) {
    int a = 0;
    for (int i = (1), _b = (n); i <= _b; i++) {
      int u;
      scanf("%d", &u);
      if (u == 1) ++a;
    }
    if (a == n)
      cout << f[n] << endl;
    else {
      long long res = f[a];
      for (int i = (a + 1), _b = (n); i <= _b; i++) res = (res * i) % MOD;
      cout << res << endl;
    }
  }
  return 0;
}
