#include <bits/stdc++.h>
using namespace std;
const int maxn = 1000010, p = 1000000007;
int n, m, dp[maxn];
int main() {
  int x, ans;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &x);
    if (x == 1) m++;
  }
  dp[0] = dp[1] = 1;
  for (int i = 2; i <= m; i++)
    dp[i] = (dp[i - 1] + (long long)dp[i - 2] * (i - 1)) % p;
  ans = dp[m];
  for (int i = m + 1; i <= n; i++) ans = (long long)ans * i % p;
  printf("%d\n", ans);
}
