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;
#define mod 1000000007
inline int read() {
    int x=0;
    char ch=getchar();
    while (!isdigit(ch)) ch=getchar();
    while (isdigit(ch)) x=x*10+ch-'0',ch=getchar();
    return x;
}
#define N 310
int fac[N],inv[N],d[N],f[N][N][2];
int main() {
    int n=read(),flg=true; fac[0]=inv[0]=fac[1]=inv[1]=1;
    for (int i=1;i<=n;i++) fac[i]=1LL*fac[i-1]*i%mod;
    for (int i=2;i<=n;i++) inv[i]=1LL*(mod-mod/i)*inv[mod%i]%mod;
    for (int i=1;i<=n;i++) inv[i]=1LL*inv[i]*inv[i-1]%mod;
    for (int i=1;i<=n;i++) d[i]=read(),flg&=(d[i]==2);
    if (flg) return printf("%d\n",1LL*fac[n-1]*inv[2]%mod),0;
    f[0][0][0]=1;
    for (int i=1;i<=n;i++)
        for (int j=0;j<=i;j++)
            for (int k=0;k<=1;k++) {
                if (d[i]>0) (f[i][j][k]+=1LL*f[i-1][j][k]*inv[d[i]-1]%mod)%mod;
                if (d[i]>1) (f[i][j][k]+=1LL*f[i-1][j-1][k]*inv[d[i]-2]%mod)%=mod;
                if (d[i]>2 && k) (f[i][j][k]+=1LL*f[i-1][j-1][0]*inv[d[i]-3]%mod)%=mod;
            }
    int ans=0;
    for (int i=3;i<=n-1;i++)
        (ans+=1LL*f[n][i][1]*fac[i-1]%mod*fac[n-i-1]%mod*inv[2]%mod)%=mod;
    cout<<ans<<endl;
    return 0;
}