#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e6 + 5;
const int MOD = 1e9 + 7;
long long ans = 1, f[MAXN];
inline int read() {
  int x = 0;
  char ch = getchar();
  while (!isdigit(ch)) ch = getchar();
  while (isdigit(ch)) {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return x;
}
inline int readin() {
  char ch = getchar();
  while (!isdigit(ch)) ch = getchar();
  return ch == '1';
}
int main() {
  int n = read(), cnt = 0;
  for (int i = 1; i <= n; i++) cnt += readin();
  f[0] = f[1] = 1;
  for (int i = 1; i <= cnt; i++) f[i] = (f[i - 2] * (i - 1) + f[i - 1]) % MOD;
  for (int i = n; i != cnt; i--) ans = 1ll * ans * i % MOD;
  printf("%lld\n", 1ll * ans * f[cnt] % MOD);
}
