#include <bits/stdc++.h>
using namespace std;
int f[505][505];
int Find(int n, int k) {
  if (n == 1) return 1;
  if (f[n][k] != -1) return f[n][k];
  if (k < n) return f[n][k] = (long long)Find(n - 1, k) * n % 1000000007;
  return f[n][k] = (Find(n - 1, n - 1) + Find(n - 1, n - 2)) % 1000000007;
}
int main() {
  int i, n, tmp, cnt = 0;
  memset(f, -1, sizeof(f));
  scanf("%d", &n);
  for (i = 0; i < n; i++) {
    scanf("%d", &tmp);
    if (tmp == 1) cnt++;
  }
  cout << Find(n, cnt) << endl;
}
