#include <bits/stdc++.h>
using namespace std;
namespace IO {
char buf_[1 << 21], *p1_ = buf_, *p2_ = buf_;
inline int in() {
  int s = 0, f = 1;
  char x = (p1_ == p2_ && (p2_ = (p1_ = buf_) + fread(buf_, 1, 1 << 21, stdin),
                           p1_ == p2_)
                ? EOF
                : *p1_++);
  for (; x < '0' || x > '9';
       x = (p1_ == p2_ && (p2_ = (p1_ = buf_) + fread(buf_, 1, 1 << 21, stdin),
                          p1_ == p2_)
                ? EOF
                : *p1_++))
    if (x == '-') f = -1;
  for (; x >= '0' && x <= '9';
       x = (p1_ == p2_ && (p2_ = (p1_ = buf_) + fread(buf_, 1, 1 << 21, stdin),
                          p1_ == p2_)
                ? EOF
                : *p1_++))
    s = (s * 10) + (x & 15);
  return f == 1 ? s : -s;
}
char buf__[1 << 21];
int pos__ = -1;
inline void flush() { fwrite(buf__, 1, pos__ + 1, stdout), pos__ = -1; }
inline void pc(char x) {
  if (pos__ == (1 << 21) - 1) flush();
  buf__[++pos__] = x;
}
inline void out(int x) {
  char k[30];
  int pos = 0;
  if (!x) return pc('0');
  if (x < 0) pc('-'), x = -x;
  while (x) k[++pos] = (x % 10) | 48, x /= 10;
  for (int i = pos; i; i--) pc(k[i]);
}
inline void out(string x) {
  int k = x.size();
  for (int i = 0; i < k; i++) pc(x[i]);
}
}  // namespace IO
using namespace IO;
const int A = 1e6 + 5;
const int mod = 1e9 + 7;
inline int add(int x, int y) { return x + y >= mod ? x + y - mod : x + y; }
inline int dec(int x, int y) { return x - y < 0 ? x - y + mod : x - y; }
inline int mul(int x, int y) {
  return (x < 0) ^ (y < 0) ? 1ll * x * y % mod + mod : 1ll * x * y % mod;
}
inline void Add(int &x, int y) { x = add(x, y); }
inline void Dec(int &x, int y) { x = dec(x, y); }
inline void Mul(int &x, int y) { x = mul(x, y); }
int n1, n2;
int f[A], g[A];
signed main() {
  int n = in();
  n1 = n2 = 0;
  for (int i = 1; i <= n; i++) {
    int u = in();
    if (u == 1)
      n1++;
    else
      n2++;
  }
  f[0] = f[1] = 1;
  for (int i = 2; i <= n1; i++) f[i] = add(f[i - 1], mul(i - 1, f[i - 2]));
  g[0] = f[n1];
  for (int i = 1; i <= n2; i++) g[i] = mul(g[i - 1], n1 + i);
  out(g[n2]), pc('\n');
  flush();
  return 0;
}
