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