#include <bits/stdc++.h>
using namespace std;
int n;
int f[555][555];
int A[555][555];
int luu[555];
int main() {
  cin >> n;
  int tmp1 = 0;
  int tmp2 = 0;
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    if (x == 1) {
      tmp1++;
    } else {
      tmp2++;
    }
  }
  memset(A, 0, sizeof(A));
  for (int i = 0; i <= n; i++) {
    A[i][0] = 1;
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= i; j++) {
      A[i][j] = (A[i - 1][j] + A[i - 1][j - 1]) % 1000000007;
    }
  }
  luu[0] = 1;
  for (int i = 1; i <= n; i++) {
    luu[i] = (long long)luu[i - 1] * i % 1000000007;
  }
  for (int i = 0; i <= tmp1; i++) {
    for (int j = 0; j <= tmp2; j++) {
      if (i == 0) {
        f[i][j] = luu[j];
      } else {
        f[i][j] = 0;
        for (int x = 0; x <= i - 1 && x <= 1; x++) {
          for (int y = 0; y <= j; y++) {
            int tmp = (long long)f[i - 1 - x][j - y] * A[j][y] % 1000000007;
            if (x == 1) {
              tmp = (long long)tmp * (i - 1) % 1000000007;
            }
            tmp = (long long)tmp * luu[x + y] % 1000000007;
            f[i][j] += tmp;
            if (f[i][j] >= 1000000007) {
              f[i][j] -= 1000000007;
            }
          }
        }
      }
    }
  }
  cout << f[tmp1][tmp2];
  return 0;
}
