#include <bits/stdc++.h>
using namespace std;
long long n, sum1, sum2, f[1000001];
signed main() {
  scanf("%lld", &n);
  for (long long i = 1; i <= n; i++) {
    long long x;
    scanf("%lld", &x);
    if (x == 1) {
      sum1++;
    } else {
      sum2++;
    }
  }
  f[0] = f[1] = 1;
  for (long long i = 2; i <= sum1; i++) {
    f[i] = (f[i - 1] + f[i - 2] * (i - 1) % 1000000007) % 1000000007;
  }
  long long ans = 1;
  for (long long i = 1; i <= sum2; i++) {
    ans = ans * (n - i + 1) % 1000000007;
  }
  printf("%lld", ans * f[sum1] % 1000000007);
  return 0;
}
