#include <bits/stdc++.h>
using namespace std;
int mo = 1000000007;
long long f[1000010];
int main() {
  long long ans;
  int n, m = 0, i, j;
  cin >> n;
  for (i = 1; i <= n; i++) scanf("%d", &j), m += j == 1;
  f[0] = 1;
  f[1] = 1;
  for (i = 2; i <= m; i++) f[i] = (f[i - 1] + f[i - 2] * (i - 1)) % mo;
  ans = f[m];
  for (i = m + 1; i <= n; i++) ans = ans * i % mo;
  cout << ans << endl;
  return 0;
}
