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 rep(i, x, y) for (int i = x; i <= y; i++)
using namespace std;

const int N = 305, mod = 1e9 + 7, inv2 = 500000004;
typedef long long ll;
ll n, d[N], f[N][N][2], fac[N], inv[N], ans, ff = 1;

void upd(ll &x, ll y) { x = (x + y) % mod; }

void init() {
    fac[0] = inv[0] = inv[1] = 1;
    rep(i, 1, n) fac[i] = fac[i - 1] * i % mod;
    rep(i, 2, n) inv[i] = (mod - mod / i) * inv[mod % i] % mod;
    rep(i, 2, n) inv[i] = inv[i] * inv[i - 1] % mod;
}

int main() {
    cin >> n;
    init();
    rep(i, 1, n) cin >> d[i], ff &= (d[i] == 2);
    if (ff) return printf("%lld\n", fac[n - 1] * inv2 % mod), 0;
    f[0][0][0] = 1;
    rep(i, 1, n) {
        rep(j, 0, i) {
            rep(k, 0, 1) {
                upd(f[i][j][k], f[i - 1][j][k] * inv[d[i] - 1] % mod);
                if (j && d[i] > 1)
                    upd(f[i][j][k], f[i - 1][j - 1][k] * inv[d[i] - 2] % mod);
                if (j && d[i] > 2 && k)
                    upd(f[i][j][1], f[i - 1][j - 1][0] * inv[d[i] - 3] % mod);
            }
        }
    }
    rep(i, 3, n - 1) upd(ans, f[n][i][1] * fac[n - i - 1] % mod * fac[i - 1] % mod * inv2 % mod);
    printf("%lld\n", ans);
    return 0;
}
