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>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

ll Pow(ll n,ll p){
	ll r=1;
	for(;p>0;p>>=1){
		if(p&1) r=(r*n)%mod;
		n=(n*n)%mod;
	}
	return r;
}


ll Div(ll n,ll m){
	return n*Pow(m,mod-2)%mod;
}

const int M=1000;
ll F[M],inv[M];

void Init(){
	F[0]=1;
	for(int i=1;i<M;i++) F[i]=F[i-1]*i%mod;
	for(int i=0;i<M;i++) inv[i]=Div(1,F[i]);
}

ll nCk(ll n,ll k){
	return Div(F[n],F[n-k]*F[k]%mod);
}
const int N=305;
ll n;
vvl dp;

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	Init();
	cin>>n;
	dp=vvl(n+1,vl(2*n+1));
	dp[0][0]++;
	bool B=1;
	for(int i=0;i<n;i++){
		vvl DP(n+1,vl(2*n+1));
		int x;
		cin>>x;
		if(x!=2) B=0;
		if(x>1){
			for(int j=0;j<n;j++) for(int k=0;k<=2*n-x+2;k++) (DP[j+1][k+x-2]+=dp[j][k]*inv[x-2])%=mod;
		}
		for(int j=0;j<=n;j++) for(int k=0;k<=2*n;k++) (DP[j][k]+=dp[j][k]*inv[x-1])%=mod;
		dp=DP;
	}
	if(B){
		cout<<Div(F[n-1],2)<<endl;
		return 0;
	}
	ll res=0;
	for(int i=3;i<n;i++) for(int j=1;j<=2*n;j++) (res+=dp[i][j]*F[n-i-1]%mod*j%mod*Div(F[i-1],2))%=mod;
	cout<<res<<endl;
}