#include <bits/stdc++.h>
using namespace std;
template <class T>
inline void read(T &x) {
  x = 0;
  register char ch = getchar();
  long long pd = 1;
  while (ch < '0' || ch > '9') {
    if (ch == '-') pd = -pd;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  x *= pd;
}
template <class T>
void write(T x) {
  if (x < 0) x = -x, putchar('-');
  if (x < 10)
    putchar(x + '0');
  else {
    write(x / 10);
    putchar(x % 10 + '0');
  }
}
template <class T>
void wrl(T x) {
  write(x);
  putchar('\n');
}
const long long N = 1e6 + 233;
const long long M = 1e9 + 7;
long long x;
long long f[2333333];
long long n;
signed main() {
  read(n);
  long long cnt = 0;
  for (register long long i = 1; i <= n; ++i) {
    read(x);
    if (x == 1) ++cnt;
  }
  f[0] = f[1] = 1;
  for (register long long i = 2; i <= cnt; ++i) {
    f[i] = ((i - 1) * f[i - 2] % M + f[i - 1]) % M;
  }
  long long ans = 1;
  for (register long long i = n; i > cnt; --i) ans = ans * i % M;
  write(ans * f[cnt] % M);
  return 0;
}
