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<iostream>
#include<cstdio>
#define mod 1000000007
using namespace std;
long long n,ans,dp[301][301][2],d[301],fac[301],invfac[301];
int read()
{
  char c=0;
  int sum=0;
  while (c<'0'||c>'9')
    c=getchar();
  while ('0'<=c&&c<='9')
    {
      sum=sum*10+c-'0';
      c=getchar();
    }
  return sum;
}
long long fast_pow(long long a,int b)
{
  if (b==0)
    return 1;
  if (b&1)
    return fast_pow(a*a%mod,b/2)*a%mod;
  else
    return fast_pow(a*a%mod,b/2);
}
int main()
{
  n=read();
  for (int i=1;i<=n;++i)
    d[i]=read();
  fac[0]=1;
  for (int i=1;i<=n;++i)
    fac[i]=fac[i-1]*i%mod;
  invfac[n]=fast_pow(fac[n],mod-2);
  for (int i=n-1;i>=0;--i)
    invfac[i]=invfac[i+1]*(i+1)%mod;
  dp[0][0][0]=1;
  for (int i=1;i<=n;++i)
    for (int j=0;j<=n;++j)
      for (int op=0;op<=1;++op)
	{
	  dp[i][j][op]=dp[i-1][j][op]*invfac[d[i]-1]%mod;
	  if (j>=1&&d[i]>=2)
	    dp[i][j][op]=(dp[i][j][op]+dp[i-1][j-1][op]*invfac[d[i]-2]%mod)%mod;
	  if (j>=1&&op&&d[i]>2)
	    dp[i][j][op]=(dp[i][j][op]+dp[i-1][j-1][0]*invfac[d[i]-3]%mod)%mod;
	}
  for (int i=3;i<=n;++i)
    ans=(ans+dp[n][i][1-(i==n)]*fac[i-1]%mod*fast_pow(2,mod-2)%mod*fac[n-i-1+(i==n)]%mod)%mod;
  printf("%lld\n",ans);
  return 0;
}