#include <bits/stdc++.h>
using namespace std;
template <class T>
inline void read(T &x) {
  x = 0;
  long long f = 0;
  char ch = getchar();
  while (!isdigit(ch)) f = ch == '-', ch = getchar();
  while (isdigit(ch)) x = (x << 1) + (x << 3) + (ch ^ 48), ch = getchar();
  x = f ? -x : x;
}
template <class T>
inline void write(T x) {
  if (x < 0) return putchar('-'), write(-x);
  if (x > 9) write(x / 10);
  putchar('0' + x % 10);
}
const long long MOD = 1e9 + 7;
const long long N = 1e6 + 5;
long long n, a, f[N], cnt;
signed main() {
  read(n);
  for (long long i = 1; i <= n; i++) read(a), cnt += (a == 1);
  f[0] = 1, f[1] = 1, f[2] = 2;
  for (long long i = 3; i <= cnt; i++)
    f[i] = (f[i - 2] * (i - 1) + f[i - 1]) % MOD;
  for (long long i = n; i > cnt; i--) f[cnt] = f[cnt] * i % MOD;
  write(f[cnt]);
  return 0;
}
