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
#include <iostream>
#define llint long long
#define mod 1000000007

using namespace std;

llint N;
llint d[305];
llint dp[305][305][305];

llint fact[605], fact_inv[605];

llint pow(llint a, llint n)
{
	if(n == 0) return 1;
	if(n % 2){
		return ((a%mod) * (pow(a, n-1)%mod)) % mod;
	}
	else{
		return pow((a*a)%mod, n/2) % mod;
	}
}

void make_fact()
{
	llint val = 1;
	fact[0] = 1;
	for(int i = 1; i < 605; i++){
		val *= i;
		val %= mod;
		fact[i] = val;
	}
	for(int i = 0; i < 605; i++){
		fact_inv[i] = pow(fact[i], mod-2);
	}
}

int main(void)
{
	cin >> N;
	for(int i = 1; i <= N; i++) cin >> d[i];
	make_fact();
	
	bool flag = false;
	for(int i = 1; i <= N; i++){
		if(d[i] < 2){
			flag = true;
			break;
		}
	}
	if(!flag){
		cout << fact[N-1] * pow(2, mod-2) % mod << endl;
		return 0;
	}
	
	
	dp[0][0][0] = 1;
	for(int i = 0; i < N; i++){
		for(int j = 0; j < N; j++){
			for(int k = 0; k <= N; k++){
				dp[i+1][j][k] += dp[i][j][k], dp[i+1][j][k] %= mod;
				if(d[i+1] >= 2) dp[i+1][j+1][k+d[i+1]-2] += dp[i][j][k] * (d[i+1]-1) % mod, dp[i+1][j+1][k+d[i+1]-2] %= mod;
			}
		}
	}
	
	llint mul = 1;
	for(int i = 1; i <= N; i++) mul *= fact_inv[d[i]-1], mul %= mod;
	mul *= pow(2, mod-2), mul %= mod;
	
	/*for(int i = 0; i <= N; i++){
		for(int j = 0; j <= N; j++){
			for(int k = 0; k <= N; k++){
				cout << dp[i][j][k] << " ";
			}
			cout << endl;
		}
		cout << endl;
	}*/
	
	llint ans = 0;
	for(int i = 3; i < N; i++){
		for(int j = 1; j <= N; j++){
			if(dp[N][i][j] == 0) continue;
			llint tmp = fact[i-1] * fact[(N-i)-1] % mod;
			tmp *= j, tmp %= mod;
			tmp *= dp[N][i][j], tmp %= mod;
			ans += tmp, ans %= mod;
		}
	}
	ans *= mul, ans %= mod;
	cout << ans << endl;
	
	return 0;
}