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
//https://vjudge.net/contest/313071#problem/B

#include<bits/stdc++.h>
const int N = 305;
const int mod = 1e9 + 7;
using namespace std;

int n, dp[N][N*2][N], f[N*2], g[N*2], a[N], ans;

void add(int&a, int b){
    a += b; if (a >= mod) a -= mod; if (a < 0) a += mod;
}

int C(int k, int n){
    if (k < 0 || k > n) return 0;
    return 1LL * f[n] * g[k] % mod * g[n-k] % mod;
}

int main(){
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    f[0] = 1; for (int i = 1; i < N*2; i++) f[i] = 1LL * f[i-1] * i % mod;
    g[0] = g[1] = 1; for (int i = 2; i < N*2; i++) g[i] = 1LL * (mod-1) * (mod / i) % mod * g[mod % i] % mod;
    for (int i = 1; i < N*2; i++) g[i] = 1LL * g[i-1] * g[i] % mod;

    cin >> n;
    for (int i = 1; i <= n; i++) cin >> a[i];
    if (n == 3) return cout << 1, 0;
    dp[0][0][0] = 1;
    for (int i = 1; i <= n; i++) for (int k = 0; k <= 2*n; k++) for (int h = 0; h <= n; h++){
        add(dp[i][k][h], 1LL * dp[i-1][k][h] * g[a[i]-1] % mod);
        if (a[i] >= 2) add(dp[i][k+a[i]-2][h+1], 1LL * dp[i-1][k][h] * C(a[i]-2, k+a[i]-2) % mod);
    }
    for (int k = 0; k <= 2*n; k++) for (int h = 3; h <= n; h++){
        if (k != 0 && h != n) add(ans, 1LL * dp[n][k][h] * f[h-1] % mod * (mod+1) / 2 % mod * g[k-1] % mod * f[n-h-1] % mod);
        if (k == 0 && h == n) add(ans, 1LL * dp[n][k][h] * f[h-1] % mod * (mod+1) / 2 % mod);
    }
    cout << ans;
}
