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>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<algorithm>
using namespace std;

const int N=309;
const int mod=1000000007;

int n,ans,i2;
int dp[N][N][N*2],d[N],fac[N*2],inv[N*2];

int quickpow(int x,int y){
	int s=1;
	for (;y;y>>=1,x=1ll*x*x%mod)
		if (y&1) s=1ll*s*x%mod;
	return s;
}

void init(){
	int i;
	fac[0]=fac[1]=inv[0]=inv[1]=1;
	for (i=2;i<=n+n;i++) fac[i]=1ll*fac[i-1]*i%mod;
	inv[n+n]=quickpow(fac[n+n],mod-2);
	for (i=n+n-1;i;i--) inv[i]=1ll*inv[i+1]*(i+1)%mod;
}

void add(int &x,int y){
	x+=y;
	(x>=mod)?x-=mod:0;
}

int main(){
	int i,j,k;
	scanf("%d",&n);
	for (i=0;i<n;i++) scanf("%d",&d[i]);
	init();
	dp[0][0][0]=1;
	for (i=0;i<n;i++)
		for (j=0;j<=i;j++)
			for (k=0;k<=n+n;k++){
				if (!dp[i][j][k]) continue;
				add(dp[i+1][j][k],1ll*dp[i][j][k]*inv[d[i]-1]%mod);
				if (d[i]>=2&&k+d[i]-2<=n+n) add(dp[i+1][j+1][k+d[i]-2],1ll*dp[i][j][k]*inv[d[i]-2]%mod);
			}
	i2=quickpow(2,mod-2);
	for (j=3;j<=n;j++)
		for (k=0;k<=n+n;k++){
			if (!dp[n][j][k]) continue;
			if (j<n&&k==0) continue;
			if (j==n&&k==0){
				add(ans,1ll*dp[n][j][k]*i2%mod*fac[n-1]%mod);
				continue;
			}
			if (j<n) add(ans,1ll*dp[n][j][k]*k%mod*fac[j-1]%mod*fac[n-j-1]%mod*i2%mod);
		}
	printf("%d\n",ans);
	return 0;
}