#include <bits/stdc++.h>
using namespace std;
const int N = 1000005;
const int mo = 1000000007;
int cnt[5], f[N], n;
int main() {
  scanf("%d", &n);
  for (int i = (1); i <= (int)n; i++) {
    int x;
    scanf("%d", &x);
    cnt[x]++;
  }
  f[0] = 1;
  for (int i = (1); i <= (int)cnt[1]; i++)
    f[i] = (f[i - 1] + 1ll * (i - 1) * f[i - 2]) % mo;
  int ans = f[cnt[1]];
  for (int i = (1); i <= (int)cnt[2]; i++) ans = 1ll * ans * (cnt[1] + i) % mo;
  printf("%d\n", ans);
}
