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 reg register
#define pr std::pair<int, int>
#define fi first
#define se second
#define FIN(s) freopen(s, "r", stdin)
#define FOUT(s) freopen(s, "w", stdout)
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define rep(i, l, r) for (int i = l; i <= r; ++i)
#define lep(i, l, r) for (int i = l; i < r; ++i)
#define irep(i, r, l) for (int i = r; i >= l; --i)
#define ilep(i, r, l) for (int i = r; i > l; --i)
#define Rep(i, n) rep(i, 1, n)
#define Lep(i, n) lep(i, 1, n)
#define IRep(i, n) irep(i, n, 1)
#define ILep(i, n) ilep(i, n, 1)
typedef long long ll;
typedef long double ld;

namespace modular {
    const int MOD = 1000000007;
    inline int add(int x, int y) { return (x += y) >= MOD ? x -= MOD : x; }
    inline void inc(int &x, int y) { (x += y) >= MOD ? x -= MOD : 0; }
    inline int mul(int x, int y) { return 1LL * x * y % MOD; }
    inline int qpow(int x, int y) {
        int ans = 1;
        for (; y; y >>= 1, x = mul(x, x))
            if (y & 1)
                ans = mul(ans, x);
        return ans;
    }
}; // namespace modular
using namespace modular;

namespace Base {
    template <typename Tp> inline Tp input() {
        Tp x = 0, y = 1;
        char c = getchar();
        while ((c < '0' || '9' < c) && c != EOF) {
            if (c == '-')
                y = -1;
            c = getchar();
        }
        if (c == EOF)
            return 0;
        while ('0' <= c && c <= '9')
            x = x * 10 + c - '0', c = getchar();
        return x *= y;
    }
    template <typename Tp> inline void read(Tp &x) { x = input<Tp>(); }
    template <typename Tp> inline void chmax(Tp &x, Tp y) { x < y ? x = y : 0; }
    template <typename Tp> inline void chmin(Tp &x, Tp y) { x > y ? x = y : 0; }
}; // namespace Base
using namespace Base;
/*----------------------------------------------------------------------------*/

#define MAX_N 3007

int N;
int d[MAX_N], fac[MAX_N], ifac[MAX_N];
int f[MAX_N][MAX_N][2];

void init() {
    int MX = 3000;
    fac[0] = ifac[0] = 1;
    Rep(i, MX) fac[i] = mul(fac[i - 1], i);
    ifac[MX] = qpow(fac[MX], MOD - 2);
    irep(i, MX, 2) ifac[i - 1] = mul(ifac[i], i);
}

void solve() {
    f[0][0][0] = 1;
    int tmp;
    Rep(i, N) {
        lep(j, 0, i) {
            rep(k, 0, 1) if (tmp = f[i - 1][j][k]) {
                // if (i == 4 && k == 1)
                //     printf("%d %d %d %d\n", i, j, k, tmp);
                inc(f[i][j][k], mul(tmp, ifac[d[i] - 1]));
                if (d[i] >= 2)
                    inc(f[i][j + 1][k], mul(tmp, ifac[d[i] - 2]));
                // if (i == 4 && j == 1 && k == 0)
                //     printf("%d\n", tmp);
                if (!k && d[i] >= 3)
                    inc(f[i][j + 1][1], mul(tmp, ifac[d[i] - 3]));
                // if (!k && d[i] >= 2)
                //     inc(f[i][j][1], mul(tmp, ifac[d[i] - 2]));
                // printf("%d %d %d %d\n", i, j, k, f[i][j][k]);
                // inc(f[i][j][0], mul(f[i - 1][j][0], ifac[d[i] - 1]));
                // inc(f[i][j + 1][0], mul(f[i - 1][j][0], ifac
            }
        }
        // rep(j, 0, i) rep(k, 0, 1) printf("%d %d %d %d\n", i, j, k,
        // f[i][j][k]);
    }
    int res = 0;
    // printf("%d\n", f[N][3][1]);
    rep(i, 3, N) inc(
        res, mul(f[N][i][1], mul(fac[N - i - 1], mul(fac[i - 1], 500000004))));
    // rep(i, 3, N)
    //     printf("%d ", mul(f[N][i][1],
    //                       mul(fac[N - i - 1], mul(fac[i - 1], 500000004))));
    // puts("");
    printf("%d\n", res);
}

int main() {
#ifdef LOCAL
    FIN("a.in");
    FOUT("a.out");
#endif
    init();
    read(N);
    bool flg = true;
    Rep(i, N) read(d[i]), flg &= (d[i] == 2);
    if (flg)
        return printf("%d\n", mul(fac[N - 1], 500000004)), 0;
    solve();
    return 0;
}
