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