#include <bits/stdc++.h>
using namespace std;
inline int max(int a, int b) { return a > b ? a : b; }
inline int min(int a, int b) { return a < b ? a : b; }
inline int gcd(int a, int b) {
  if (a % b)
    return gcd(b, a % b);
  else
    return b;
}
inline int lcm(int a, int b) { return (a * (b / gcd(a, b))); }
inline int And(int mask, int bit) { return mask & (1 << bit); }
inline int Or(int mask, int bit) { return mask | (1 << bit); }
inline int Xor(int mask, int bit) { return mask & (~(1 << bit)); }
long long dp[1000100], f[1000100], ans;
int x, n, cnt;
long long power(long long x, int y) {
  long long res = 1LL;
  while (y) {
    if (y & 1) res = (res * x) % 1000000007;
    y >>= 1;
    x = (x * x) % 1000000007;
  }
  return res;
}
int main() {
  dp[0] = dp[1] = 1LL;
  f[0] = f[1] = 1LL;
  for (int i = 2; i <= 1000000; i++) {
    dp[i] = (dp[i - 1] + (i - 1) * dp[i - 2]) % 1000000007;
    f[i] = (f[i - 1] * i) % 1000000007;
  }
  scanf("%d", &n);
  cnt = 0;
  for (int i = 0; i < n; i++) {
    scanf("%d", &x);
    if (x == 1) cnt++;
  }
  ans = (f[n] * dp[cnt]) % 1000000007;
  ans *= power(f[cnt], 1000000007 - 2);
  ans %= 1000000007;
  printf("%I64d\n", ans);
  return 0;
}
