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 N=5005,md=1000000007;
int n,i,j,d[N],f[N][N][2],ans,inv[N],jc[N],rjc[N];
int main()
{
	scanf("%d",&n);
	for(i=1;i<=n;++i)
		scanf("%d",d+i);
	inv[0]=inv[1]=1;
	for(i=2;i<=n;++i)
		inv[i]=1ll*inv[md%i]*(md-md/i)%md;
	jc[0]=rjc[0]=1;
	for(i=1;i<=n;++i)
		jc[i]=1ll*jc[i-1]*i%md,rjc[i]=1ll*rjc[i-1]*inv[i]%md;
	f[0][0][0]=1;
	for(i=1;i<=n;++i)
		for(j=0;j<=n;++j)
		{
			f[i][j][0]=((j>=1&&d[i]>=2?1ll*f[i-1][j-1][0]*rjc[d[i]-2]%md:0)+1ll*f[i-1][j][0]*rjc[d[i]-1]%md)%md;
			f[i][j][1]=((j>=1&&d[i]>=2?1ll*f[i-1][j-1][1]*rjc[d[i]-2]%md:0)+(j>=1&&d[i]>=3?1ll*f[i-1][j-1][0]*rjc[d[i]-3]%md:0)+1ll*f[i-1][j][1]*rjc[d[i]-1]%md)%md;
		}
	for(i=3,j=1;i<n;++i)
	{
		ans=(ans+1ll*f[n][i][1]*j%md*jc[n-i-1]%md)%md;
		j=1ll*j*i%md;
	}
	for(i=1;i<=n;++i)
		if(d[i]!=2)
			break;
	if(i>n)
		ans=(ans+j)%md;
	printf("%d",ans);
	return 0;
}
