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;
/*
	Author		zombie462
	Date&Time 	Unknown
*/
#define int long long
#define LL long long
#define uLL unsigned long long
#define LD long double
//#define N 0
//#define M 0
//#define mod 0
//#define G 0
#define reg register
//#pragma GCC optimize("O2")
int read(){
	int x=0,f=1;
	char ch=getchar();
	while (ch<'0' || ch>'9'){
		if (ch=='-') f=-1;
		ch=getchar();
	}
	while (ch>='0' && ch<='9'){
		x=x*10+ch-'0';ch=getchar();
	}
	return x*f;
}
/*
int etot=1,ea[N*2],eb[N*2],ec[N],ed[N*2];
void add(int x,int y,int z=0){
	etot++;ea[etot]=y;eb[etot]=ec[x];ec[x]=etot;ed[etot]=z;
}
*/
/*
int gcd(int x,int y){
	if (x%y==0) return y;
	else return gcd(y,x%y);
}
int lcm(int x,int y){
	return x*y/gcd(x,y);
}
int getinv(int x){
	if (x==1) return 1;
	else return (mod-mod/x)*getinv(mod%x)%mod;
}
*/
/*
int inv[G],fac[G];
int C(int n,int m){
	if (n==m) return 1;
	if (n<m) return 0;
	return fac[n]*inv[m]%mod*inv[n-m]%mod;
}
void initC(){
	inv[0]=inv[1]=fac[0]=fac[1]=1;
	for (int i=1;i<G;++i) fac[i]=fac[i-1]*i%mod;
	for (int i=1;i<G;++i) inv[i]=(mod-mod/i)*inv[mod%i]%mod;
	for (int i=1;i<G;++i) inv[i]=inv[i]*inv[i-1]%mod;
}
*/
#define mod 1000000007
#define N 1010
int d[N],fac[N],inv[N],f[N][N][2];
signed main(){
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);

	int n=read();
	fac[0]=fac[1]=1;
	for (int i=2;i<=n;++i) fac[i]=fac[i-1]*i%mod;
	inv[0]=inv[1]=1;
	for (int i=2;i<=n;++i) inv[i]=(mod-mod/i)*inv[mod%i]%mod;
	int inv2=inv[2];
	for (int i=2;i<=n;++i) inv[i]=inv[i]*inv[i-1]%mod;
	for (int i=1;i<=n;++i) d[i]=read();
	f[0][0][0]=1;
	for (int i=0;i<n;++i){
		for (int j=0;j<=i;++j){
			f[i+1][j][0]=(f[i+1][j][0]+f[i][j][0]*(inv[d[i+1]-1])%mod)%mod;
			f[i+1][j][1]=(f[i+1][j][1]+f[i][j][1]*(inv[d[i+1]-1])%mod)%mod;
			if (d[i+1]<2) continue;
			f[i+1][j+1][0]=(f[i+1][j+1][0]+f[i][j][0]*(inv[d[i+1]-2])%mod)%mod;
			f[i+1][j+1][1]=(f[i+1][j+1][1]+f[i][j][1]*(inv[d[i+1]-2])%mod)%mod;
			if (d[i+1]<3) continue;
			f[i+1][j+1][1]=(f[i+1][j+1][1]+f[i][j][0]*(inv[d[i+1]-3])%mod)%mod;
		}
	}
	int ans=0;
	for (int j=3;j<n;++j) ans=(ans+f[n][j][1]*fac[n-j-1]%mod*fac[j-1]%mod*inv2%mod)%mod;
	if (n>=3) ans=(ans+f[n][n][0]*fac[n-1]%mod*inv2%mod);
	cout<<ans<<endl;
	
	fclose(stdin);
	fclose(stdout);
	return 0;
}
/*
--Some models can copy to use--
Coming soon...
*/
