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 pb push_back
#define mp make_pair
using namespace std;

template<typename T>inline void upmin(T&x,T y){y<x?x=y:0;}
template<typename T>inline void upmax(T&x,T y){x<y?x=y:0;}

typedef unsigned int u32;
typedef long long LL;
typedef unsigned long long ULL;
typedef long double lod;
typedef pair<int,int> PR;
typedef vector<int>VI;

const lod pi=acos(-1);
const int oo=1<<30;
const LL OO=1e18;
const int N=310;

int gi(){
	int w=0;bool q=1;char c=getchar();
	while((!isdigit(c))&& c!='-')c=getchar();
	if(c=='-')q=0,c=getchar();
	while(isdigit(c))w=w*10+c-'0',c=getchar();
	return q?w:-w;
}

const int mod=1e9+7;
int f[N][N][2],inv[N],fac[N];

int main(){
	int n=gi(),i,j,k,d,w;
	for(i=fac[0]=1;i<=n;++i) fac[i]=1LL*fac[i-1]*i%mod;
	for(i=2,inv[0]=inv[1]=1;i<=n;i++) inv[i]=mod-1LL*(mod/i)*inv[mod%i]%mod;
	for(i=3;i<=n;++i)inv[i]=1LL*inv[i]*inv[i-1]%mod;
	f[0][0][0]=1;
	for(i=0;i<n;++i){
		d=gi()-1;
		for (j=0;j<=i;++j)
			for (k=0;k<2;++k)
				if(w=f[i][j][k]){
					f[i+1][j][k]=(f[i+1][j][k]+1LL*w*inv[d])%mod;
					if(d){
						f[i+1][j+1][k]=(f[i+1][j+1][k]+1LL*w*inv[d-1])%mod;
						if (!k&&d>1)
							f[i+1][j+1][1]=(f[i+1][j+1][1]+1LL*w*inv[d-2])%mod;
					}
				}
	}
	for (j=3,d=0;j<n;++j)
		d=(d+1LL*f[n][j][1]*fac[j-1]%mod*fac[n-(j-1)-2])%mod;
	d=(d+1LL*f[n][n][0]*fac[n-1])%mod;
	d=1LL*d*((mod+1)>>1)%mod;
	printf("%d\n",d);
	return 0;
}