#include <bits/stdc++.h>
using namespace std;
template <class T>
inline T min(T &a, T &b) {
  return a < b ? a : b;
}
template <class T>
inline T max(T &a, T &b) {
  return a > b ? a : b;
}
template <class T>
void read(T &x) {
  char ch;
  while ((ch = getchar()) && !isdigit(ch))
    ;
  x = ch - '0';
  while ((ch = getchar()) && isdigit(ch)) x = x * 10 + ch - '0';
}
long long Pow(long long a, long long b, long long Mod) {
  long long ans = 1;
  a %= Mod;
  for (; b; b >>= 1) ans = b & 1 ? (ans * a % Mod) : ans, a = a * a % Mod;
  return ans;
}
int Mod = 1000000007, n, x, c, f[1000001];
int main() {
  read(n);
  for (int i = 1; i <= n; i++) read(x), c += x == 1;
  f[0] = f[1] = 1;
  f[2] = 2;
  for (int i = 3; i <= c; i++)
    f[i] = ((long long)f[i - 1] + (long long)(i - 1) * f[i - 2]) % Mod;
  for (int i = c + 1; i <= n; i++) f[c] = ((long long)f[c] * i) % Mod;
  printf("%d\n", f[c]);
}
