#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  int n, m(0), x;
  cin >> n;
  for (int i = 0; i < n; ++i) {
    cin >> x;
    if (x == 1) m++;
  }
  const int mod = 1e9 + 7;
  long long a[2] = {1, 1};
  for (int i = 1; i < m; ++i)
    if (i % 2)
      a[0] = (a[1] + i * a[0]) % mod;
    else
      a[1] = (a[0] + i * a[1]) % mod;
  long long ans = a[m % 2];
  for (int i = m + 1; i <= n; ++i) ans = (ans * i) % mod;
  cout << ans;
  return 0;
}
