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<cstdio>

const int P=1000000007;
int n,d[305],fac[305],inv[305],f[305][305][2],ans;

int power(int a,int x){
	int ans=1;
	for(;x;x>>=1,a=1ll*a*a%P)if(x&1)ans=1ll*ans*a%P;
	return ans;
}
void upd(int &x,int y){x=x+y>=P?x+y-P:x+y;}

int main(){
	scanf("%d",&n);
	bool cir=true;
	for(int i=1;i<=n;i++)scanf("%d",d+i),cir&=d[i]==2;
	for(int i=fac[0]=1;i<=n;i++)fac[i]=1ll*fac[i-1]*i%P;
	inv[n]=power(fac[n],P-2);
	for(int i=n;i;i--)inv[i-1]=1ll*inv[i]*i%P;
	if(cir&&n>=3)ans=1ll*fac[n-1]*inv[2]%P;
	f[0][0][0]=1;
	for(int i=0;i<n;i++)
		for(int j=0;j<=n;j++)
			for(int k=0;k<2;k++){
				if(!f[i][j][k])continue;
				upd(f[i+1][j][k],f[i][j][k]);
				if(d[i+1]>=2)
					upd(f[i+1][j+1][k],1ll*f[i][j][k]*(d[i+1]-1)%P);
				if(!k&&d[i+1]>=3)
					upd(f[i+1][j+1][1],1ll*f[i][j][k]*(d[i+1]-1)%P*(d[i+1]-2)%P);
			}
	for(int i=3;i<n;i++)
		upd(ans,1ll*fac[i-1]*inv[2]%P*f[n][i][1]%P*fac[n-i-1]%P);
	for(int i=1;i<=n;i++)ans=1ll*ans*inv[d[i]-1]%P;
	printf("%d\n",ans);
	return 0;
}
