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<bits/stdc++.h>
using namespace std;
typedef long long ll;
inline int read()
{
	int x=0,f=1;char c=getchar();
	while(!isdigit(c)){if(c=='-')f=-1;c=getchar();}
	while(isdigit(c)){x=x*10+c-'0';c=getchar();}
	return x*f;
}
const int maxn=310;
const int maxv=500010;
const int mod=1e9+7;
int n,d[maxn];
ll fac[maxv],inv[maxv],f[maxn][maxn][maxn],anc[maxv];
template<typename T> inline void sol(T &x){if(x>=mod)x%=mod;}
inline void init()
{
	fac[0]=fac[1]=inv[0]=inv[1]=anc[0]=anc[1]=1;
	for(int i=2;i<=maxn;i++) fac[i]=fac[i-1]*i%mod;
	for(int i=2;i<=maxn;i++) inv[i]=(mod-mod/i)*inv[mod%i]%mod;
	for(int i=2;i<=maxn;i++) anc[i]=anc[i-1]*inv[i],sol(anc[i]);
//	printf("%lld\n",fac[100]*anc[100]%mod);
}
int main()
{
	init();
	n=read();for(int i=0;i<n;i++) d[i]=read();
	
	//special_judge
	bool flag=1;for(int i=0;i<n;i++) if(d[i]!=2){flag=0;break;}
	if(flag) return printf("%lld\n",fac[n-1]%mod*inv[2]%mod),0;
	//end of special_judge
	f[0][0][0]=1;
	for(int i=0;i<n;i++)
		for(int j=0;j<=i;j++)
		{
			for(int k=0;k<=n;k++)
			{
//				printf("%d %d %d %lld\n",i,j,k,f[i][j][k]);
				f[i+1][j][k]+=f[i][j][k]*anc[d[i]-1]%mod;sol(f[i+1][j][k]);
				if(d[i]>=2) f[i+1][j+1][k+d[i]-2]+=f[i][j][k]*anc[d[i]-2]%mod,sol(f[i+1][j+1][k+d[i]-2]); 
			}
		}
	
	ll ans=0;
	for(int i=3;i<n;i++)
		for(int j=0;j<=n;j++) 
//			printf("%d %d %lld\n",i,j,f[n][i][j]),
			ans+=f[n][i][j]*fac[n-i-1]%mod*j%mod*inv[2]%mod*fac[i-1]%mod,sol(ans);
	printf("%lld\n",ans);
	return 0;
}