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<algorithm>
const int Mod=1e9+7;
const int inv2=(Mod+1)/2;
typedef long long ll;
int n,deg[5100];
ll fac[5100],inv[5100],f[5100][5100][2],ans;
int main(){
    scanf("%d",&n); bool flag=1;
    fac[0]=1; for (int i=1;i<=n;i++) fac[i]=fac[i-1]*i%Mod;
	inv[1]=1; for (int i=2;i<=n;i++) inv[i]=(Mod-Mod/i)*inv[Mod%i]%Mod;
	inv[0]=1; for (int i=1;i<=n;i++) inv[i]=inv[i-1]*inv[i]%Mod;
    for (int i=1;i<=n;i++){
    	scanf("%d",&deg[i]);
		flag=flag&&(deg[i]==2);
	}
    if (flag){
		printf("%lld\n",fac[n-1]*inv2%Mod);
		return 0;
	}
    f[0][0][0]=1;
    for (int i=0;i<n;i++)
        for (int j=0;j<=i;j++)
            for (int k=0;k<2;k++){
                if (deg[i+1]>0) f[i+1][j][k]=(f[i+1][j][k]+f[i][j][k]*inv[deg[i+1]-1])%Mod;
                if (deg[i+1]>1) f[i+1][j+1][k]=(f[i+1][j+1][k]+f[i][j][k]*inv[deg[i+1]-2])%Mod;
                if (deg[i+1]>2&&!k) f[i+1][j+1][1]=(f[i+1][j+1][1]+f[i][j][k]*inv[deg[i+1]-3])%Mod;
            }
    for (int i=3;i<n;i++) ans=(ans+f[n][i][1]*fac[n-i-1]%Mod*fac[i-1]%Mod*inv2)%Mod;
	printf("%lld\n",ans);
    return 0;
}