#include <bits/stdc++.h>
using namespace std;
const long long M = 1e9 + 7;
inline long long read() {
  long long re = 0, k = 1;
  char ch = getchar();
  while (ch > '9' || ch < '0') {
    if (ch == '-') k = -1;
    ch = getchar();
  }
  while (ch <= '9' && ch >= '0') {
    re = re * 10 + ch - 48;
    ch = getchar();
  }
  return re * k;
}
inline void write(long long x) {
  if (x < 0) return putchar('-'), write(-x), void();
  if (x < 10) return putchar(x + '0'), void();
  return write(x / 10), putchar(x % 10 + '0'), void();
}
long long n, lim1, f[1000005], ans = 1;
signed main() {
  n = read();
  for (register long long i = 1; i <= n; i++) {
    long long a = read();
    if (a == 1) lim1++;
  }
  f[0] = f[1] = 1;
  for (register long long i = 2; i <= lim1; i++)
    f[i] = (f[i - 1] + (i - 1) * f[i - 2]) % M;
  for (register long long i = n; i > lim1; i--) ans = ans * i % M;
  write(ans * f[lim1] % M);
}
