#include <bits/stdc++.h>
using namespace std;
int n;
set<vector<int> > s;
void att(vector<int> a, int d[]) {
  s.insert(a);
  for (int i = 0; i < n; i++)
    if (d[i])
      for (int j = i + 1; j < n; j++)
        if (d[j]) {
          d[i]--;
          d[j]--;
          swap(a[i], a[j]);
          att(a, d);
          swap(a[i], a[j]);
          d[i]++;
          d[j]++;
        }
}
int calc() {
  int d[11] = {0};
  s.clear();
  for (int i = 0; i < n; i++) d[i] = 1;
  vector<int> a(n);
  for (int i = 0; i < n; i++) a[i] = i;
  att(a, d);
  return s.size();
}
int main() {
  int d1 = 0, x, ans[11][11];
  ans[1][0] = ans[1][1] = 1;
  for (n = 2; n <= 10; n++) {
    ans[n][n] = calc();
    for (int i = 0; i < n; i++) ans[n][i] = ans[n - 1][i] * n;
  }
  cin >> n;
  for (int i = 0; i < n; i++) cin >> x, d1 += (x == 1);
  cout << ans[n][d1] << endl;
}
