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 GET_MACRO(_1, _2, _3, NAME, ...) NAME
#define _repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define _rep(i,n) _repl(i,0,n)
#define rep(...) GET_MACRO(__VA_ARGS__, _repl, _rep)(__VA_ARGS__)
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back((a))
#define all(x) (x).begin(),(x).end()
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#define fi first
#define se second
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
void _dbg(string){cout<<endl;}
template<class H,class... T> void _dbg(string s,H h,T... t){int l=s.find(',');cout<<s.substr(0,l)<<" = "<<h<<", ";_dbg(s.substr(l+1),t...);}
template<class T,class U> ostream& operator<<(ostream &o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream &o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

#define INF 1120000000
#define MOD 1000000007

long mod_pow(long x, long n, long p=MOD){
  if(x==0) return 0;
  long res=1;
  x %= p;
  while(n>0){
    if(n&1) res=res*x%p;
    x=x*x%p;
    n>>=1;
  }
  return res;
}
inline long mod_inv(long x, long p=MOD){ return mod_pow(x%p, p-2, p); }

long fact[303];

long dp[2][303][303];

int main(){
  int n;
  cin>>n;
  vector<int> v(n);
  rep(i,n) cin>>v[i];

  fact[0] = 1;
  rep(i,300) fact[i+1] = (i+1)*fact[i] %MOD;

  if(all_of(all(v), [](int x){return x==2;})){
    cout << fact[n-1] * mod_inv(2) %MOD << endl;
    return 0;
  }

  // dp[i][j][k] iまでj個使ってk個のサイクル外へのパス
  auto pre = dp[0];
  auto nxt = dp[1];
  fill(pre[0], pre[n], 0);
  pre[0][0] = 1;
  rep(i,n) if(v[i]>1){
    rep(j,n) rep(k,n){
      nxt[j][k] = pre[j][k];
      int pj = j-1;
      int pk = k - (v[i]-2);
      if(pj>=0 && pk>=0 && pre[pj][pk]>0){
        nxt[j][k] += pre[pj][pk] * (v[i]-1);
        nxt[j][k] %= MOD;
      }
    }
    swap(pre, nxt);
  }

  long ans = 0;
  rep(i,3,n) rep(j,1,n) if(pre[i][j]>0){
    // dbg(i,j,pre[i][j]);
    assert(n-i >= j);
    long tmp = fact[i-1] * fact[n-i-1] %MOD;
    tmp = tmp * j %MOD;
    tmp = tmp * pre[i][j] %MOD;
    ans += tmp;
  }
  ans %= MOD;

  long muls = 1;
  rep(i,n) muls = muls * fact[v[i]-1] %MOD;

  ans = ans * mod_inv(2*muls %MOD) %MOD;

  cout << ans << endl;

  return 0;
}

/*
map<vector<int>,int> ma = {
  {{2,2,2}, 1},
  {{1,2,2,3}, 1},
  {{2,2,2,2}, 3},
  {{1,1,2,2,4}, 1},
  {{1,1,2,3,3}, 2},
  {{1,2,2,2,3}, 6},
  {{2,2,2,2,2}, 12}
};
*/
