#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9 + 7;
long long n, v0, v1, x, y, line, row, ans = 1LL;
template <typename T>
inline T read(T &x) {
  T flg = 1;
  x = 0;
  char ch = getchar();
  while (!isdigit(ch)) {
    if (ch == '-') flg = -flg;
    ch = getchar();
  }
  while (isdigit(ch)) x = (x << 3) + (x << 1) + (ch ^ 48), ch = getchar();
  return x *= flg;
}
template <typename T>
inline void write(T x) {
  if (x < 0) x = -x, putchar('-');
  if (x > 9) write(x / 10);
  putchar(x % 10 + '0');
}
template <typename T>
inline void writeln(T x) {
  write(x);
  puts("");
}
template <typename T>
inline void writesp(T x) {
  write(x);
  putchar(' ');
}
inline long long ksm(long long b, long long p) {
  long long res = 1;
  while (p) {
    if (p & 1) res = res * b % MOD;
    b = b * b % MOD;
    p >>= 1;
  }
  return res;
}
signed main() {
  read(n);
  for (register long long i = 1; i <= n; ++i) {
    read(x);
    if (x == 1)
      ++v1;
    else
      ++v0;
  }
  for (register long long i = 2; i <= v0 + v1; ++i) ans = ans * i % MOD;
  if (v1 < 3) {
    write(ans);
    return 0;
  }
  x = y = 1LL;
  for (register long long i = 3; i <= v1; ++i) {
    line = (x + y) % MOD;
    row = x * i % MOD;
    ans = ans * ksm(row, MOD - 2) % MOD * line % MOD;
    x = line;
    y = row;
  }
  write(ans);
  return 0;
}
