#include <bits/stdc++.h>
using namespace std;
int n, x = 0, y = 0;
long long ans = 1, l[(1000000 + 10)];
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) {
    int p;
    scanf("%d", &p);
    if (p == 1) x++;
  }
  y = n - x;
  l[0] = l[1] = 1;
  for (int i = 2; i <= x; i++)
    l[i] = (l[i - 1] + l[i - 2] * (i - 1)) % (1000000007);
  ans = l[x];
  for (int i = x + 1; i <= n; i++) ans = (ans * i) % (1000000007);
  cout << ans << endl;
  return 0;
}
