#include <bits/stdc++.h>
using namespace std;
int ans[12][15] = {
    {},
    {1, 1},
    {2, 2, 2},
    {6, 6, 6, 4},
    {24, 24, 24, 16, 10},
    {120, 120, 120, 80, 50, 26},
    {720, 720, 720, 480, 300, 156, 76},
    {5040, 5040, 5040, 3360, 2100, 1092, 532, 232},
    {40320, 40320, 40320, 26880, 16800, 8736, 4256, 1856, 764},
    {362880, 362880, 362880, 241920, 151200, 78624, 38304, 16704, 6876, 2620},
    {3628800, 3628800, 3628800, 2419200, 1512000, 786240, 383040, 167040, 68760,
     26200, 9496}};
int a[20];
int main() {
  int n, i, sum = 0;
  scanf("%d", &n);
  for (i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    if (a[i] == 1) sum++;
  }
  printf("%d\n", ans[n][sum]);
  return 0;
}
