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 <cstdio>
#include <cstring>
#include <cmath>
#include <iostream>
#include <algorithm>
#define M 5005
#define mod 1000000007
int n,D[M];
long long fac[M],inv[M],fac_inv[M],F[M][M][2],ans;
int read(){
	char c=getchar();int ans=0;
	while (c<'0'||c>'9') c=getchar();
	while (c>='0'&&c<='9') ans=ans*10+c-'0',c=getchar();
	return ans;
}
void Write(long long x){
	if (x<10) putchar(x^48);
	else Write(x/10),putchar((x%10)^48);
	return;
}
int main(){
	n=read();bool flag=1;fac[0]=fac[1]=inv[1]=fac_inv[0]=fac_inv[1]=1;
	for (register int i=2;i<=n;i++)
		fac[i]=fac[i-1]*i%mod,inv[i]=(mod-mod/i)*inv[mod%i]%mod,fac_inv[i]=fac_inv[i-1]*inv[i]%mod;
	for (register int i=1;i<=n;i++) D[i]=read(),flag&=(D[i]==2);
	if (flag){Write(fac[n-1]*inv[2]%mod);return 0;}
	F[0][0][0]=1;
	for (register int i=0;i<n;i++)
		for (register int j=0;j<=i;j++)
			for (register int k=0;k<2;k++){
				if (D[i+1]>0) F[i+1][j][k]=(F[i+1][j][k]+F[i][j][k]*fac_inv[D[i+1]-1])%mod;
				if (D[i+1]>1) F[i+1][j+1][k]=(F[i+1][j+1][k]+F[i][j][k]*fac_inv[D[i+1]-2])%mod;
				if (D[i+1]>2&&!k) F[i+1][j+1][1]=(F[i+1][j+1][1]+F[i][j][k]*fac_inv[D[i+1]-3])%mod;
			}
	for (register int i=3;i<n;i++) ans=(ans+F[n][i][1]*fac[n-i-1]%mod*fac[i-1]%mod*inv[2])%mod;
	Write(ans);
	return 0;
}
