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;
const int MaxN(5003),Mod(1000000007);
int d[MaxN],f[MaxN][MaxN][2],fac[MaxN],inv[MaxN];
int fexp(int x,int k)
{
	int res=1;
	while(k)
	{
		if(k&1) res=1ll*res*x%Mod;
		x=1ll*x*x%Mod;
		k>>=1;
	}
	return res;
}
inline void upd(int &x,int y)
{ (x+=y)%=Mod; }
inline int mul(int x,int y)
{ return 1ll*x*y%Mod; }
int main()
{
	int N,Ans=0;
	bool flag=1;
	scanf("%d",&N);
	for(int i=1;i<=N;i++)
		scanf("%d",&d[i]);
	fac[0]=1,inv[0]=1;
	for(int i=1;i<=N;i++)
	{
		fac[i]=1ll*fac[i-1]*i%Mod;
		inv[i]=fexp(fac[i],Mod-2);
		flag&=d[i]==2;
	}
	if(flag)
	{
		printf("%d\n",1ll*fac[N-1]*inv[2]%Mod);
		return 0;
	}
	f[0][0][0]=1;
	for(int i=1;i<=N;i++)
		f[0][0][0]=mul(f[0][0][0],inv[d[i]-1]);
	for(int i=1;i<=N;i++)
	{
		for(int j=0;j<i;j++)
			for(int k=0;k<=1;k++)
				f[i][j][k]=f[i-1][j][k];
		if(d[i]>1)
			for(int j=0;j<i;j++)
				for(int k=0;k<=1;k++)
					upd(f[i][j+1][k],mul(f[i-1][j][k],mul(fac[d[i]-1],inv[d[i]-2])));
		if(d[i]>2)
			for(int j=0;j<i;j++)
				upd(f[i][j+1][1],mul(f[i-1][j][0],mul(fac[d[i]-1],inv[d[i]-3])));
	}
	for(int i=3;i<N;i++)
		upd(Ans,mul(f[N][i][1],mul(fac[N-i-1],mul(fac[i-1],inv[2]))));
	printf("%d\n",Ans);
	return 0;
}
