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

const int N=305;
const int mod=1000000007;

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

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]=inv[0]=1;
	for (i=1;i<=n;i++) fac[i]=1ll*fac[i-1]*i%mod;
	inv[n]=quickpow(fac[n],mod-2);
	for (i=n-1;i;i--) inv[i]=1ll*inv[i+1]*(i+1)%mod;
}

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