Kyoya Ootori has a bag with n colored balls that are colored with k different colors. The colors are labeled from 1 to k. Balls of the same color are indistinguishable. He draws balls from the bag one by one until the bag is empty. He noticed that he drew the last ball of color i before drawing the last ball of color i + 1 for all i from 1 to k - 1. Now he wonders how many different ways this can happen. 

Input

The first line of input will have one integer k (1 ≤ k ≤ 1000) the number of colors.

Then, k lines will follow. The i-th line will contain ci, the number of balls of the i-th color (1 ≤ ci ≤ 1000).

The total number of balls doesn't exceed 1000.

Output

A single integer, the number of ways that Kyoya can draw the balls from the bag as described in the statement, modulo 1 000 000 007. 

Examples

Input

3
2
2
1


Output

3


Input

4
1
2
3
4


Output

1680

Note

In the first sample, we have 2 balls of color 1, 2 balls of color 2, and 1 ball of color 3. The three ways for Kyoya are: 
    
    
      
    1 2 1 2 3  
    1 1 2 2 3  
    2 1 1 2 3  
    
25
35
43
38
33
47
44
40
36
41
42
33
30
49
42
62
39
40
35
43
31
42
46
42
34
33
 47
20
21
16
18
24
20
25
13
20
22
26
24
17
18
21
22
21
23
17
15
24
19
18
21
20
19
26
25
20
17
17
17
26
32
20
21
25
28
24
21
21
17
28
20
20
31
19
 3
343
317
337
 1
5
 10
100
100
100
100
100
100
100
100
100
100
 1
1
 13
67
75
76
80
69
86
75
86
81
84
73
72
76
 5
10
10
10
10
10
 11
291
381
126
39
19
20
3
1
20
45
2

362689152
 295545118
 691446102
 1
 12520708
 1
 232242896
 425711769
 902382672

/*Author: Satyajeet Singh, Delhi Technological University*/
import java.io.*;
import java.util.*;
import java.text.*; 
import java.lang.*;

public class Main {
	static PrintWriter out=new PrintWriter(new OutputStreamWriter(System.out));		
    static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	static long mod=(long)1e9+7;
	static long mod1=998244353;
	static boolean sieve[];
	static ArrayList<Integer> primes;
	static ArrayList<Long> factorial;
/****************************************Solutions Begins***************************************************/
	public static void main (String[] args) throws Exception {
		String st[]=br.readLine().split(" ");
		int k=Integer.parseInt(st[0]);
		int input[]=new int[k+1];

		fact(2000);
		int n=0;

		for(int i=1;i<=k;i++){
			st=br.readLine().split(" ");
			input[i]=Integer.parseInt(st[0]);
			n+=input[i];			
		}
		long ans=1;
		for(int i=k;i>=2;i--){
			//System.out.println(n+" "+input[i]);
			long h=ncr(n-1,input[i]-1);
			n-=input[i];
			ans=(ans*h)%mod;
		}
		out.println(ans);
	
/****************************************Solutions Ends*****************************************************/
		out.flush();
		out.close();
    }
/****************************************Template Begins***************************************************/

/*******************************************************TRIPLET********************************************/
	static class tripletComparator implements Comparator<triplet>{
		public int compare(triplet p1,triplet p2){
			if(p1.u<p2.u){
				return 1;
			}
			else if(p1.u>p2.u){
				return -1;
			}
			else{
				return 0;
			}
		}
	}
	static class triplet{
		int u;
		int v;
		int i;
		public triplet(int u,int v,int i){
			this.u=u;
			this.v=v;
			this.i=i;
		}
		public String toString() {
			return "[u=" + u + ", v=" + v + ", i="+i+"]";
		}
	}
/*********************************************PAIR*************************************************/
	static class PairComp implements Comparator<Pair>{
		public int compare(Pair p1,Pair p2){
			if(p1.u>p2.u){
				return 1;
			}
			else if(p1.u<p2.u){
				return -1;
			}
			else{
				return 0;
			}
		}
	}
	static class Pair implements Comparable<Pair> {
		int u;
		int v;
		int index=-1;
		public Pair(int u, int v) {
			this.u = u;
			this.v = v;
		}
 
		public int hashCode() {
			int hu = (int) (u ^ (u >>> 32));
			int hv = (int) (v ^ (v >>> 32));
			return 31 * hu + hv;
		}
 
		public boolean equals(Object o) {
			Pair other = (Pair) o;
			return u == other.u && v == other.v;
		}
 
		public int compareTo(Pair other) {
			if(index!=other.index)
				return Long.compare(index, other.index);
			return Long.compare(v, other.v)!=0?Long.compare(v, other.v):Long.compare(u, other.u);
		}
 
		public String toString() {
			return "[u=" + u + ", v=" + v + "]";
		}
	}
/*******************************************LONG PAIR******************************************/
	static class PairCompL implements Comparator<Pairl>{
		public int compare(Pairl p1,Pairl p2){
			if(p1.u>p2.u){
				return 1;
			}
			else if(p1.u<p2.u){
				return -1;
			}
			else{
				return 0;
			}
		}
	}
static class Pairl implements Comparable<Pair> {
		long u;
		long v;
		int index=-1;
		public Pairl(long u, long v) {
			this.u = u;
			this.v = v;
		}
 
		public int hashCode() {
			int hu = (int) (u ^ (u >>> 32));
			int hv = (int) (v ^ (v >>> 32));
			return 31 * hu + hv;
		}
 
		public boolean equals(Object o) {
			Pair other = (Pair) o;
			return u == other.u && v == other.v;
		}
 
		public int compareTo(Pair other) {
			if(index!=other.index)
				return Long.compare(index, other.index);
			return Long.compare(v, other.v)!=0?Long.compare(v, other.v):Long.compare(u, other.u);
		}
 
		public String toString() {
			return "[u=" + u + ", v=" + v + "]";
		}
	}
/*****************************************DEBUG***********************************************************/
	public static void debug(Object... o) {
		System.out.println(Arrays.deepToString(o));
	}
/*****************************************NUMBER THEORY***********************************************/

/************************************MODULAR EXPONENTIATION************************************/
	static long modulo(long a,long b,long c) {
		long x=1;
		long y=a;
		while(b > 0){
			if(b%2 == 1){
				x=(x*y)%c;
			}
			y = (y*y)%c; // squaring the base
			b /= 2;
		}
		return  x%c;
	}
/*********************************************GCD*****************************/
	static long gcd(long x, long y)
	{
		if(x==0)
			return y;
		if(y==0)
			return x;
		long r=0, a, b;
		a = (x > y) ? x : y; // a is greater number
		b = (x < y) ? x : y; // b is smaller number
		r = b;
		while(a % b != 0)
		{
			r = a % b;
			a = b;
			b = r;
		}
		return r;
	}
/*******************************************SIEVE*********************************/
	static void sieveMake(int n){
		sieve=new boolean[n];
		Arrays.fill(sieve,true);
		sieve[0]=false;
		sieve[1]=false;
		for(int i=2;i*i<n;i++){
			if(sieve[i]){
				for(int j=i*i;j<n;j+=i){
					sieve[j]=false;
				}
			}
		}
		primes=new ArrayList<Integer>();
		for(int i=0;i<n;i++){
			if(sieve[i]){
				primes.add(i);
			}
		}		
	}
/***************************************FACTORIAL*********************************************************/
	static void fact(int n){
		factorial=new ArrayList<>();
		factorial.add((long)1);
		for(int i=1;i<=n;i++){
			factorial.add((factorial.get(i-1)*i)%mod);
		}
	}
/*******************************************ncr*********************************************************/
	static long ncr(int n,int k){
		long aa=modulo(factorial.get(n-k),mod-2,mod);
		long bb=modulo(factorial.get(k),mod-2,mod);
		long cc=factorial.get(n);
		long ans=(aa*cc)%mod;
		ans=(ans*bb)%mod;
		return ans;
	}
/***************************************STRING REVERSE****************************************************/
	static String reverse(String str){
		char r[]=new char[str.length()];
		int j=0;
		for(int i=str.length()-1;i>=0;i--){
			r[j]=str.charAt(i);
			j++;
		}
		return new String(r);
	}
}
/*******************************************************End***********************************************************/