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;

const int N = 305;
const int mod = 1e9 + 7;

int n, a[N], f[N][N][N], inv[N], prd[N];

void add(int &x, int y) {
	x = (x + y) >= mod ? x + y - mod : x + y; 
}

int pw(int x, int y) {
	if (!y) return 1;
	int ret = pw(x, y >> 1); ret = 1LL * ret * ret % mod;
	if (y & 1) ret = 1LL * ret * x % mod; return ret; 
}

int C(int k, int n) {
	return 1LL * prd[n] * inv[k] % mod * inv[n - k] % mod;
}

int cal(int x) {
	return 1LL * C(2, x - 1) * prd[x - 3] % mod;
}

int main() {
	ios::sync_with_stdio(false);
	cin >> n;
	for (int i = 1; i <= n; ++i) cin >> a[i];
	prd[0] = 1; 
	for (int i = 1; i <= n; ++i) prd[i] = 1LL * i * prd[i - 1] % mod;
	inv[n] = pw(prd[n], mod - 2);
	for (int i = n; i >= 1; --i) inv[i - 1] = 1LL * inv[i] * i % mod;
	f[0][0][0] = 1;
	for (int i = 0; i < n; ++i) {
		for (int j = 0; j <= n; ++j) {
			for (int k = 0; k <= i; ++k) {
				if (!f[i][j][k]) continue;
				add(f[i + 1][j][k], f[i][j][k]);
				if (a[i + 1] >= 2) {
					add(f[i + 1][j + a[i + 1] - 2][k + 1], 1LL * f[i][j][k] * prd[a[i + 1] - 1] % mod * C(a[i + 1] - 2, j + a[i + 1] - 2) % mod);
				}
			}
		}
	} 
	int res = 0;
	for (int i = 0; i <= n; ++i) {
		for (int j = 3; j <= n; ++j) {
			if (!f[n][i][j]) continue;
			if (n == j && i == 0) {
				add(res, 1LL * f[n][i][j] * cal(j) % mod); continue;
			}
			if (n == j || i == 0) continue;
			int val = 1LL * inv[i - 1] * prd[n - j - 1] % mod * cal(j) % mod;
			for (int k = 1; k <= n; ++k) val = 1LL * val * inv[a[k] - 1] % mod;
			add(res, 1LL * val * f[n][i][j] % mod);
		}
	}
	cout << res;
}