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 bp __builtin_popcountll
#define pb push_back
#define in(s) freopen(s, "r", stdin);
#define out(s) freopen(s, "w", stdout);
#define inout(s, end1, end2) freopen((string(s) + "." + end1).c_str(), "r", stdin),\
		freopen((string(s) + "." + end2).c_str(), "w", stdout);
#define fi first
#define se second
#define bw(i, r, l) for (int i = r - 1; i >= l; i--)
#define fw(i, l, r) for (int i = l; i < r; i++)
#define fa(i, x) for (auto i: x)
using namespace std;
const int mod = 1e9 + 7, inf = 1061109567;
const long long infll = 4557430888798830399;
const int N = 605;
int n, d[N], fac[N], ifac[N], dp[305][305][N], fixedDetominator = 1, sumOfAllDegrees = 0;
void add(int &x, int y) {
	x += y; if (x >= mod) x -= mod;
}
int mul(int x, int y) {
	return 1ll * x * y % mod;
}
int fpow(int a, int p) {
	if (!p) return 1;
	int tmp = fpow(a, p >> 1);
	tmp = mul(tmp, tmp);
	if (p & 1) tmp = mul(tmp, a);
	return tmp;
}
int inv(int a) {
	return fpow(a, mod - 2);
}
int calc(int sz, int sumOfDegrees, int productOfDegrees) {
	sumOfDegrees -= 2 * sz;
	int numerator = 1, detominator = 1;
	numerator = mul(numerator, fac[n - sz - 1]);
	numerator = mul(numerator, sumOfDegrees);
	numerator = mul(numerator, fac[sz - 1]);
	numerator = mul(numerator, productOfDegrees);
	
	detominator = fixedDetominator;
	return mul(numerator, detominator);
}
signed main() {
	#ifdef BLU
	in("blu.inp");
	#endif
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	fac[0] = 1;
	fw (i, 1, N) fac[i] = mul(fac[i - 1], i);
	fw (i, 0, N) ifac[i] = inv(fac[i]);
	cin >> n;
	fw (i, 0, n) cin >> d[i], sumOfAllDegrees += d[i];
	bool allCycle = 1;
	fw (i, 0, n) if (d[i] != 2) allCycle = 0;
	if (allCycle) {
		//Permute (n!), divide by rotations (n) and reverses (2). So (n - 1)! / 2.
		int ans = fac[n - 1];
		ans = mul(ans, inv(2));
		cout << ans;
		return 0;
	}
	//We have a formula if the cycle vertexes are fixed, depending on sum of degrees, number of vertexes and
	//product of degrees.
	fixedDetominator = 2;
	fw (i, 0, n) fixedDetominator = mul(fixedDetominator, fac[d[i] - 1]);
	fixedDetominator = inv(fixedDetominator);
	//dp[i][sz][deg]: Sum of product of degrees within sz of the first i vertexes, deg is sum of degrees.
	dp[0][0][0] = 1;
	fw (i, 0, n) fw (sz, 0, i + 2) fw (deg, 0, sumOfAllDegrees + 1) if (dp[i][sz][deg]) {
//		cout << "dp[" << i << "][" << sz << "][" << deg << "] = " << dp[i][sz][deg] << "\n";
		add(dp[i + 1][sz][deg], dp[i][sz][deg]);
		if (d[i] > 1) {
			//Add i into the cycle
			add(dp[i + 1][sz + 1][deg + d[i]], mul(dp[i][sz][deg], d[i] - 1));
		}
	}
	int ans = 0;
	fw (sz, 3, n + 1) fw (deg, 0, sumOfAllDegrees + 1) if (dp[n][sz][deg]) {
//		cout << "dp[" << n << "][" << sz << "][" << deg << "] = " << dp[n][sz][deg] << "\n";
		add(ans, calc(sz, deg, dp[n][sz][deg]));
	}
	cout << ans;
	return 0;
}