#include <bits/stdc++.h>
const int N = 1000000 + 9, MOD = 1000000000 + 7;
int f[N], n, a, b;
int main() {
  scanf("%d", &n);
  for (int i = 1, x; i <= n; ++i) {
    scanf("%d", &x);
    if (x == 1)
      ++a;
    else
      ++b;
  }
  f[1] = 1;
  f[0] = 1;
  for (int i = 2; i <= a; ++i)
    f[i] = (f[i - 1] + 1ll * f[i - 2] * (i - 1) % MOD) % MOD;
  int ans = f[a];
  for (int i = 1; i <= b; ++i) ans = 1ll * ans * (i + a) % MOD;
  printf("%d\n", ans);
}
