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>
#include<iostream>
#include<cstring>
#include<algorithm>

using namespace std;

const int N=5009,M=1000000007;
int n,d[N],inv[N],F[N],f[N][N][2],flag;

void init()
{
	scanf("%d",&n);
	for (int i=1;i<=n;i++)
		scanf("%d",&d[i]),flag+=(d[i]==2);
}

int ksm(int a,int b)
{
	int res=1;
	while(b)
	{
		if(b&1)
			res=1LL*res*a%M;
		b>>=1,a=1LL*a*a%M;
	}
	return res;
}

void add(int &x,int y)
{
	x=(x+y)%M;
}

void work()
{
	F[0]=inv[0]=1;
	for (int i=1;i<=n;i++)
		F[i]=1LL*F[i-1]*i%M;
	inv[n]=ksm(F[n],M-2);
	for (int i=n-1;i>=1;i--)
		inv[i]=1LL*inv[i+1]*(i+1)%M;
	//printf("%d\n",(int)(1LL*F[n]*inv[n]%M));
	int inv2=ksm(2,M-2);
	if(flag==n)
	{
		printf("%d\n",(int)(1LL*F[n-1]*inv2%M));
		return;
	}
	f[0][0][0]=1;
	for (int i=0;i<n;i++)
		for (int j=0;j<=i;j++)
			for (int k=0;k<=1;k++)
			{
				if(f[i][j][k]==0)
					continue;
				add(f[i+1][j][k],1LL*f[i][j][k]*inv[d[i+1]-1]%M);
				if(d[i+1]>1)
					add(f[i+1][j+1][k],1LL*f[i][j][k]*inv[d[i+1]-2]%M);
				if(d[i+1]>2&&!k)
					add(f[i+1][j+1][1],1LL*f[i][j][k]*inv[d[i+1]-3]%M);
			}
	int ans=0;
	for (int i=3;i<n;i++)
		add(ans,1LL*f[n][i][1]*inv2%M*F[n-i-1]%M*F[i-1]%M);
	printf("%d\n",ans);
}

int main()
{
	init();
	work();
	return 0;
}
