#include <bits/stdc++.h>
using namespace std;
const int N = 1000000 + 5;
const int MOD = 1000000007;
int n, cnt;
long long ans, f[N];
int main(int argc, char **argv) {
  int x;
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) scanf("%d", &x), cnt += (x == 1);
  f[0] = f[1] = 1;
  for (int i = 2; i <= cnt; ++i) f[i] = (f[i - 1] + f[i - 2] * (i - 1)) % MOD;
  ans = f[cnt];
  for (int i = cnt + 1; i <= n; ++i) ans = ans * i % MOD;
  cout << ans << endl;
  return 0;
}
