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
/*Lucky_Glass*/
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;

const int MOD=1e9+7,N=610,INV2=500000004;

#define cs const int &
inline int Add(cs a,cs b){return a+b>=MOD? a+b-MOD:a+b;}
inline int Sub(cs a,cs b){return a-b<0? a-b+MOD:a-b;}
inline int Mul(cs a,cs b){return 1ll*a*b%MOD;}
inline int Pow(int a,int b){int r=1;while(b){if(b&1)r=Mul(r,a);a=Mul(a,a),b>>=1;}return r;}

int n;
int d[N],fac[N],ifac[N];
int f[2][N][N];

int main(){
	fac[0]=1;for(int i=1;i<N;i++) fac[i]=Mul(fac[i-1],i);
	ifac[N-1]=Pow(fac[N-1],MOD-2);for(int i=N-2;i>=0;i--) ifac[i]=Mul(ifac[i+1],i+1);
	scanf("%d",&n);
	int cnt2=0,all=0;
	for(int i=1;i<=n;i++) scanf("%d",&d[i]),cnt2+=d[i]==2,all+=d[i];
	if(cnt2==n){printf("%d\n",Mul(fac[n-1],INV2));return 0;}
	f[0][0][0]=1;
	for(int i=1,I=1;i<=n;i++,I^=1)
		for(int j=0;j<=i;j++)
			for(int k=0;k<=all;k++){
				f[I][j][k]=f[I^1][j][k];
				if(j && d[i]>=2 && k>=d[i])
					f[I][j][k]=Add(f[I][j][k],Mul(f[I^1][j-1][k-d[i]],d[i]-1));
			}
	int ans=0,pod=1;
	for(int i=1;i<=n;i++) pod=Mul(pod,ifac[d[i]-1]);
	for(int S=3;S<n;S++)
		for(int de=2*S;de<=all;de++){
			int mul=Mul(fac[S-1],fac[n-S-1]);
			mul=Mul(mul,Mul(INV2,pod));
			mul=Mul(mul,Sub(de,2*S));
			// printf("[%d][%d]=%d\n",S,de,f[n&1][S][de]);
			ans=Add(ans,Mul(mul,f[n&1][S][de]));
		}
	printf("%d\n",ans);
	return 0;
}
