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;
#define maxn 310
const int p=1e9+7;
const int inv2=500000004;
template <typename T>inline T read()
{
    register T sum=0;
    register char cc=getchar();
    int sym=1;
    while(cc!='-'&&(cc>'9'||cc<'0'))cc=getchar();
    if(cc=='-')sym=-1,cc=getchar();
    sum=sum*10+cc-'0';
    cc=getchar();
    while(cc>='0'&&cc<='9')sum=sum*10+cc-'0',cc=getchar();
    return sym*sum;
}
template <typename T>inline T read(T &a)
{
    a=read<T>();
    return a;
}
template <typename T,typename... Others> inline void read(T& a, Others&... b)
{
    a=read(a);
	read(b...);
}
int n,ans,flg=true,D[maxn],f[maxn][maxn][2],jc[maxn],inv[maxn],ifac[maxn];
void Add(int &x,int y)
{
	x+=y;
	if(x>=p)
		x-=p;
}
int mul(int x,int y)
{
	return 1ll*x*y%p;
}
int main()
{
	read(n);
	jc[0]=inv[0]=ifac[0]=1;
	jc[1]=inv[1]=ifac[1]=1;
	for(int i=2;i<=n;i++)
	{
		jc[i]=mul(jc[i-1],i);
		inv[i]=mul(p-p/i,inv[p%i]);
		ifac[i]=mul(ifac[i-1],inv[i]);
	}
	for(int i=1;i<=n;i++)
	{
		read(D[i]);
		flg&=D[i]==2;
	}
	if(flg)
	{
		printf("%d\n",mul(jc[n-1],inv2));
		return 0;
	}
	f[0][0][0]=1;
	for(int i=0;i<n;i++)
		for(int j=0;j<=i;j++)	
			for(int k:{0,1})
			{
				if(!f[i][j][k])
					continue;
				if(D[i+1]>0)
					Add(f[i+1][j][k],mul(ifac[D[i+1]-1],f[i][j][k]));
				if(D[i+1]>1)
					Add(f[i+1][j+1][k],mul(ifac[D[i+1]-2],f[i][j][k]));
				if(D[i+1]>2&&!k)
					Add(f[i+1][j+1][1],mul(ifac[D[i+1]-3],f[i][j][k]));
			}
	for(int i=3;i<n;i++)
		Add(ans,mul(mul(jc[i-1],inv2),mul(jc[n-i-1],f[n][i][1])));
	printf("%d\n",ans);
    return 0;
}
