#include <bits/stdc++.h>
int n, c1, c2;
int dp[1001000] = {1, 1};
int main() {
  int i, x;
  scanf("%d", &n);
  for (i = 1; i <= n; ++i) {
    scanf("%d", &x);
    if (x == 1)
      ++c1;
    else
      ++c2;
  }
  for (i = 2; i <= c1; ++i)
    dp[i] = ((long long)(i - 1) * dp[i - 2] + dp[i - 1]) % 1000000007;
  for (i = 1; i <= c2; ++i) dp[c1] = (long long)dp[c1] * (c1 + i) % 1000000007;
  printf("%d\n", dp[c1]);
  return 0;
}
