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>
using namespace std;
const long mod=1e9+7;
long power(long a,long b){return b?power(a*a%mod,b/2)*(b%2?a:1)%mod:1;}
int N;
int d[300];
long dp[2][301][601];
long fac[601],invfac[601],inv[301];
int main()
{
	cin>>N;
	fac[0]=1;
	for(int i=1;i<=2*N;i++)fac[i]=fac[i-1]*i%mod;
	for(int i=0;i<=2*N;i++)invfac[i]=power(fac[i],mod-2);
	for(int i=1;i<=N;i++)inv[i]=power(i,mod-2);
	bool isroop=true;
	for(int i=0;i<N;i++)
	{
		cin>>d[i];
		if(d[i]!=2)isroop=false;
	}
	if(isroop)
	{
		cout<<fac[N-1]*inv[2]%mod<<endl;
		return 0;
	}
	int now=0;
	dp[now][0][0]=1;
	int c2=0;
	for(int i=0;i<N;i++)
	{
		if(d[i]<=2)
		{
			if(d[i]==2)c2++;
			continue;
		}
		for(int j=0;j<=N;j++)for(int k=0;k<=2*N;k++)dp[1-now][j][k]=0;
		for(int j=0;j<N;j++)for(int k=0;k<=2*N;k++)
		{
			if(dp[now][j][k]==0)continue;
			(dp[1-now][j][k]+=dp[now][j][k]*invfac[d[i]-1])%=mod;
			(dp[1-now][j+1][k+d[i]-2]+=dp[now][j][k]*invfac[d[i]-2])%=mod;
		}
		now=1-now;
	}
	for(int i=1;i<=N;i++)for(int j=1;j<=2*N;j++)(dp[now][i][j]*=inv[2])%=mod;
	for(int _=0;_<c2;_++)
	{
		for(int j=0;j<=N;j++)for(int k=0;k<=2*N;k++)dp[1-now][j][k]=0;
		for(int j=1;j<=N;j++)for(int k=1;k<=2*N;k++)
		{
			if(dp[now][j][k]==0)continue;
			(dp[1-now][j][k]+=dp[now][j][k])%=mod;
			(dp[1-now][j+1][k]+=dp[now][j][k])%=mod;
		}
		now=1-now;
	}
	long ans=0;
	for(int i=3;i<N;i++)for(int j=1;j<=2*N;j++)
	{
		(ans+=dp[now][i][j]*fac[N-1-i]%mod*fac[i-1]%mod*j%mod)%=mod;
	}
	cout<<ans<<endl;
}
