#include <bits/stdc++.h>
const int maxn = 1000005, mod = 1000000007;
int n, cnt1, cnt2, ans;
int f[maxn];
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    int x;
    scanf("%d", &x);
    if (x == 1)
      cnt1++;
    else
      cnt2++;
  }
  f[0] = f[1] = 1;
  for (int i = 2; i <= cnt1; i++)
    f[i] = (1ll * f[i - 2] * (i - 1) % mod + f[i - 1]) % mod;
  ans = 1;
  for (int i = n; i >= n - cnt2 + 1; i--) ans = 1ll * ans * i % mod;
  printf("%d\n", 1ll * f[cnt1] * ans % mod);
  return 0;
}
