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 Fail puts("NO"),exit(0);
#define eps 1e-10
#define maxn 305
#define maxm 4010
#define inf 1000000007
#define mod 1000000007
#define G 3
#define pi acos(-1)
#define mp(x,y) make_pair(x,y)
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int>pii;
typedef bitset<maxn> bit;
int read()
{
    int x=0,f=1;
    char ch=getchar();
    while(ch-'0'<0||ch-'0'>9){if(ch=='-') f=-1;ch=getchar();}
    while(ch-'0'>=0&&ch-'0'<=9){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
int n;
int d[maxn];
bool check()
{
    for(int i=1;i<=n;i++)
      if(d[i]!=2) return false;
    return true;
}
int quick_pow(int x,int p)
{
    int an=1,po=x;
    while(p)
    {
        if(p&1)  an=1ll*an*po%mod;
        po=1ll*po*po%mod;
        p>>=1;
    }
    return an;
}
int fac[maxn],inv[maxn];
void pre_work()
{
    fac[0]=1;
    for(int i=1;i<=n;i++)  fac[i]=1ll*fac[i-1]*i%mod;
    inv[n]=quick_pow(fac[n],mod-2);
    for(int i=n-1;i>=0;i--) inv[i]=1ll*inv[i+1]*(i+1)%mod;
}
int ans;
int f[maxn][maxn][2];
void add(int &x,int y)
{
    x=(x+y>=mod)?x+y-mod:x+y;
}
int main()
{
    n=read();
    for(int i=1;i<=n;i++)  d[i]=read();
    pre_work();
    if(check())
    {
        ans=1ll*fac[n-1]*inv[2]%mod;
        cout<<ans<<endl;
        return 0;
    }
    f[0][0][0]=1;
    for(int i=1;i<=n;i++)
    {
        for(int j=0;j<=i-1;j++)
        {
            for(int k=0;k<2;k++)
            {
                if(!f[i-1][j][k])  continue;
                add(f[i][j][k],1ll*f[i-1][j][k]*inv[d[i]-1]%mod);
                if(d[i]>=2)  add(f[i][j+1][k],1ll*f[i-1][j][k]*inv[d[i]-2]%mod);
                if(d[i]>=3&&!k)  add(f[i][j+1][1],1ll*f[i-1][j][k]*inv[d[i]-3]%mod);
            }
        }
    }
    for(int i=3;i<n;i++)  ans=(ans+1ll*f[n][i][1]*fac[n-i-1]%mod*fac[i-1]%mod*inv[2]%mod)%mod;
    cout<<ans<<endl;
    return 0;
}