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<algorithm>
#include<iostream>
#include<vector>
#include<cstdio>
#include<cstring>
using namespace std;
#define ll long long
//{{{ read()
inline ll read(){
	register ll x=0,f=1;
	register char ch=getchar();
	while(ch<'0'||ch>'9'){
		if(ch=='-')	f=-1;
		ch=getchar();
	}
	while(ch>='0'&&ch<='9')	x=x*10+(ch^48),ch=getchar();
	return x*f;
}
//}}}
const int P=1e9+7;
const int N=305;
ll fac[N],inv[N],f[N][2];
ll fsp(ll x,int y=P-2){
	ll ans=1;
	while(y){
		if(y&1)	ans=ans*x%P;
		x=x*x%P,y>>=1;
	}
	return ans;
}
int n,d[N],ans;
int main(){
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	n=read(),fac[0]=inv[0]=1;
	for(int i=1;i<=n;i++)	d[i]=read();
	for(int i=1;i<=n;i++){
		fac[i]=fac[i-1]*i%P;
		inv[i]=fsp(fac[i]);
	}
	f[0][0]=1;
	for(int i=1;i<=n;i++){
		for(int j=i;~j;j--){
			f[j][0]=f[j][0]*inv[d[i]-1]%P;
			f[j][1]=f[j][1]*inv[d[i]-1]%P;
			if(d[i]>1&&j){
				f[j][0]=(f[j][0]+f[j-1][0]*inv[d[i]-2])%P;
				f[j][1]=(f[j][1]+f[j-1][1]*inv[d[i]-2])%P;
			}
			if(d[i]>2)	f[j][1]=(f[j][1]+f[j-1][0]*inv[d[i]-3])%P;
		}
	}
	for(int i=3;i<n;i++)	ans=(ans+f[i][1]*fac[n-i-1]%P*fac[i-1]%P*inv[2])%P;

	int flag=1;
	for(int i=1;i<=n;i++)
		if(d[i]<2)	flag=0;
	if(flag)	ans=(ans+fac[n-1]*inv[2])%P;
	printf("%d\n",ans);
	return 0;
}
