#include <bits/stdc++.h>
long long dp[1000100];
int main() {
  int n, two, i, a;
  long long r;
  scanf("%d", &n);
  for (i = two = 0; i < n; i++) scanf("%d", &a), two += a == 1;
  if (n == 1) {
    puts("1");
    return 0;
  }
  dp[0] = 1;
  dp[1] = 1;
  dp[2] = 2;
  dp[3] = 4;
  for (i = 4; i <= n; i++)
    dp[i] = (dp[i - 1] + (i - 1LL) * dp[i - 2]) % 1000000007;
  r = dp[two];
  for (i = two + 1; i <= n; i++) r = (r * i) % 1000000007;
  printf("%I64d\n", r);
  return 0;
}
