Snuke has come up with the following problem.

> You are given a sequence d of length N. Find the number of the undirected graphs with N vertices labeled 1,2,...,N satisfying the following conditions, modulo 10^{9} + 7:
>
>   * The graph is simple and connected.
>   * The degree of Vertex i is d_i.
>


When 2 \leq N, 1 \leq d_i \leq N-1, {\rm Σ} d_i = 2(N-1), it can be proved that the answer to the problem is \frac{(N-2)!}{(d_{1} -1)!(d_{2} - 1)! ... (d_{N}-1)!}.

Snuke is wondering what the answer is when 3 \leq N, 1 \leq d_i \leq N-1, { \rm Σ} d_i = 2N. Solve the problem under this condition for him.

Constraints

* 3 \leq N \leq 300
* 1 \leq d_i \leq N-1
* { \rm Σ} d_i = 2N

Input

Input is given from Standard Input in the following format:


N
d_1 d_2 ... d_{N}


Output

Print the answer.

Examples

Input

5
1 2 2 3 2


Output

6


Input

16
2 1 3 1 2 1 4 1 1 2 1 1 3 2 4 3


Output

555275958
#if 0
date +%Y.%m.%d

solution will be written here.
#endif
#include <cstdio>
#include <algorithm>
#define debug(...) fprintf(stderr, __VA_ARGS__)

typedef long long ll;
struct {
	inline operator int () { int x; return scanf("%d", &x), x; }
	inline operator ll () { ll x; return scanf("%lld", &x), x; }
} read;

const int maxn = 5050, mod = 1000000007;
int deg[maxn];
ll fac[maxn], ifac[maxn];
ll f[2][maxn][2];

ll power(ll x, int k) {
	if(k < 0) k += mod - 1;
	ll res = 1;
	while(k) {
		if(k & 1) (res *= x) %= mod;
		(x *= x) %= mod;
		k >>= 1;
	}
	return res;
}

int main() {
	int n = read;
	for(int i = 1; i <= n; i ++)
		deg[i] = read;

	fac[0] = 1;
	for(int i = 1; i <= n; i ++)
		fac[i] = fac[i - 1] * i % mod;
	ifac[n] = power(fac[n], -1);
	for(int i = n; i; i --)
		ifac[i - 1] = ifac[i] * i % mod;

	f[0][0][0] = 1;
	for(int i = 1; i <= n; i ++) {
		int o = i & 1;
		for(int j = 0; j <= i; j ++)
			f[o][j][0] = f[o][j][1] = 0;
		for(int j = 0; j < i; j ++)
			for(int p = 0; p < 2; p ++) {
				ll x = f[!o][j][p];
				if(deg[i] >= 1)
					f[o][j][p] += x * ifac[deg[i] - 1];
				if(deg[i] >= 2)
					f[o][j + 1][p] += x * ifac[deg[i] - 2];
				if(deg[i] >= 3 and !p)
					f[o][j + 1][1] += x * ifac[deg[i] - 3];
			}
		for(int j = 0; j <= i; j ++)
			f[o][j][0] %= mod, f[o][j][1] %= mod;
	}

	ll ans = f[n & 1][n][0] * fac[n - 1] % mod * ifac[2] % mod;
	for(int k = 3; k < n; k ++)
		(ans += f[n & 1][k][1] * fac[n - k - 1] % mod *
		 fac[k - 1] % mod * ifac[2]) %= mod;
	printf("%lld\n", ans);
}
