#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
const int N = 1e6 + 5;
int n, cnt[3], dp[N], sum = 1;
int add(int x, int y) { return (1ll * x + 1ll * y) % mod; }
int mul(int x, int y) { return (1ll * x * 1ll * y) % mod; }
int del(int x, int y) { return ((1ll * x - 1ll * y) % mod + mod) % mod; }
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    int x;
    scanf("%d", &x);
    cnt[x]++;
  }
  dp[0] = 1;
  dp[1] = 1;
  for (int i = 2; i <= cnt[1]; i++)
    dp[i] = add(dp[i - 1], mul(dp[i - 2], i - 1));
  for (int i = 1; i <= cnt[2]; i++) sum = mul(sum, cnt[1] + i);
  printf("%d", mul(sum, dp[cnt[1]]));
}
