#include <bits/stdc++.h>
using namespace std;
int const factor[10] = {1, 2, 6, 24, 120, 720, 5040, 40320, 362880, 3628800};
int dat[100] = {1, 2, 4, 10, 26, 76, 232, 764, 2620, 9496};
int main() {
  int n;
  while (~scanf("%d", &n)) {
    int a, c1 = 0, c2 = 0;
    int ret = 1;
    for (int i = 0; i < n; ++i) {
      scanf("%d", &a);
      if (a == 1) ++c1;
      if (a == 2) ++c2;
    }
    if (c1 == 0 && c2 == 0) {
      cout << 1 << endl;
    } else if (c1 == 0 && c2 > 0) {
      cout << factor[c2 - 1] << endl;
    } else {
      ret *= factor[c1 + c2 - 1];
      ret -= 1LL * (factor[c1 - 1] - dat[c1 - 1]) * factor[c1 + c2 - 1] /
             factor[c1 - 1];
      cout << ret << endl;
    }
  }
  return 0;
}
