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<stdio.h>
#define it register int
#define ct const int
#define il inline
#define P 1000000007
const int N=5005;
int fac[N],inv[N],ifac[N],a[N],f[N][N][2],ans,n;
bool flag;
int main(){
	scanf("%d",&n);it i,j,k;
	for(i=1;i<=n;++i) scanf("%d",&a[i]),flag|=(a[i]^2);
	fac[0]=fac[1]=ifac[0]=ifac[1]=inv[0]=inv[1]=1;
	for(i=2;i<=n;++i)
		fac[i]=(0ll+fac[i-1])*i%P,inv[i]=(0ll+inv[P%i])*(P-P/i)%P,ifac[i]=(0ll+ifac[i-1])*inv[i]%P;
	if(!flag) return printf("%d",(0ll+fac[n-1])*inv[2]%P),0;//大环
	f[0][0][0]=1;
	//f[i][j][0/1] : i个点 选择了环上j个点 是否选了一个度数为 d - 3 的点
	for(i=0;i<n;++i)
		for(j=0;j<n;++j)
			for(k=0;k<2;++k){
				if(f[i][j][k]){
					if(a[i+1]>0) //树
						f[i+1][j][k]=(f[i+1][j][k]+(0ll+f[i][j][k])*ifac[a[i+1]-1])%P;
					if(a[i+1]>1) //环
						f[i+1][j+1][k]=(f[i+1][j+1][k]+(0ll+f[i][j][k])*ifac[a[i+1]-2])%P;
					if(a[i+1]>2&&!k) //最后一个d-3还没选，把这个点选上去
						f[i+1][j+1][1]=(f[i+1][j+1][1]+(0ll+f[i][j][0])*ifac[a[i+1]-3])%P;
				}
			}
	for(i=3;i<n;++i) ans=(ans+(0ll+fac[i-1])*inv[2]%P*fac[n-i-1]%P*f[n][i][1])%P;
	printf("%d",ans); 
	return 0;
}
