#include <bits/stdc++.h>
using namespace std;
int n, a, b, I[1111111];
int main(int argc, char* argv[]) {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    int x;
    scanf("%d", &x);
    if (x == 1)
      a++;
    else
      b++;
  }
  I[0] = I[1] = 1;
  for (int i = 2; i <= a; i++)
    I[i] = (I[i - 1] + 1ll * (i - 1) * I[i - 2]) % 1000000007;
  int ans = 1;
  for (int i = a + 1; i <= a + b; i++) ans = (1ll * ans * i) % 1000000007;
  ans = (1ll * I[a] * ans) % 1000000007;
  cout << ans << endl;
  return 0;
}
