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 <algorithm>  
#include <iostream>  
#include <sstream>  
#include <string>  
#include <cstring>
#include <vector>  
#include <queue>  
#include <set>  
#include <map>  
#include <cstdio>  
#include <cstdlib>  
#include <cctype>  
#include <cmath>  
#include <list>  
#include <cassert>
#include <ctime>
#include <climits>
using namespace std;  

#define PB push_back  
#define MP make_pair  
#define SZ(v) ((int)(v).size())  
#define FOR(i,a,b) for(int i=(a);i<(b);++i)  
#define REP(i,n) FOR(i,0,n)  
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)  
#define REPE(i,n) FORE(i,0,n)  
#define FORSZ(i,a,v) FOR(i,a,SZ(v))  
#define REPSZ(i,v) REP(i,SZ(v))  
typedef long long ll;
typedef unsigned long long ull;
ll gcd(ll a,ll b) { return b==0?a:gcd(b,a%b); }

const int MAXN = 300;
const int MOD = 1000000007;

// ncyc in cycle -> dcyclesum
// N'=N-ncyc+1, i not in cycle: di'=di -> di<=N-ncyc, icyc: dicyc'=dcyclesum-2*ncyc -> dcyclesum-ncyc<=N (always true)

int n;
int d[MAXN];

int fac[2 * MAXN + 1];
int inv[2 * MAXN + 1];
int ifac[2 * MAXN + 1];

int dp[MAXN + 1][2 * MAXN + 1]; // dp[i][j] = the sum of for each way of (selecting i items for the cycle with total sum j-2*i) the product of ifac[d[i]-2] for them and ifac[d[i]-1] for others

void run() {
	fac[0] = 1; FORE(i, 1, 2 * MAXN) fac[i] = (ll)fac[i - 1] * i%MOD;
	inv[1] = 1; FORE(i, 2, 2 * MAXN) inv[i] = (MOD - (ll)(MOD / i)*inv[MOD%i] % MOD) % MOD;
	ifac[0] = 1; FORE(i, 1, 2 * MAXN) ifac[i] = (ll)ifac[i - 1] * inv[i] % MOD;

	scanf("%d", &n); REP(i, n) scanf("%d", &d[i]);
	//n = 300; REP(i, n) d[i] = i / 100 + 1;


	memset(dp, 0, sizeof(dp)); dp[0][0] = 1;
	int mxdx = 0;
	REP(k, n) {
		for (int i = k; i >= 0; --i) REPE(j, mxdx) if (dp[i][j] != 0) {
			if (d[k] >= 2)	dp[i + 1][j + d[k] - 2] = (dp[i + 1][j + d[k] - 2] + (ll)ifac[d[k] - 2] * dp[i][j]) % MOD;
			dp[i][j] = (ll)dp[i][j] * ifac[d[k] - 1] % MOD;
		}
		if (d[k] >= 2) mxdx += d[k] - 2;
	}

	int ret = 0;
	FORE(ncyc, 3, n) REPE(dx, mxdx) {
		int dpval = dp[ncyc][dx]; if (dpval == 0) continue;
		assert(dx <= n - ncyc);
		int nn = n - ncyc + 1, ntree;
		if (dx == 0) {
			if (nn != 1) continue; else ntree = 1;
		} else {
			if (nn < 2) continue; else ntree = (ll)fac[nn - 2] * dpval%MOD*ifac[dx - 1] % MOD;
		}
		int cur = (ll)ntree*fac[ncyc - 1] % MOD*inv[2] % MOD*fac[dx] % MOD;
		ret = (ret + cur) % MOD;
	}
	printf("%d\n", ret);
}

int main() {
	run();
	return 0;
}
