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

import java.util.*;
import java.io.*;
import java.math.*;

public class A{
	final static long modulo = 1000000007;
	static int n,a[];
	static class BigCal{
		private static long pow[],dv[],f[];//def[],inf[],f[];
		static void init(int n){
			pow=new long [n+1];
			dv=new long[n+1];
			//def=new long[n+1]; inf=new long[n+1];
			f=new long[n+1];
			
			int i; long j;
			for (i=0;i<dv.length;i++) dv[i]=i;
			for (i=2;i<dv.length;i++)if (dv[i]==i){
				for (j=i;(i*j)<dv.length;j++) dv[(int)(i*j)]=i;	
			}
			Arrays.fill(pow, 0);
			Arrays.fill(f, 0);//Arrays.fill(inf, 0);Arrays.fill(def, 0);
		}
		static void multiply(int x,long p){
			if (x<=1) return;
			pow[(int)dv[x]]+=p;
			multiply((int)(x/dv[x]),p);
		}
		static void multiplyFact(int x){
			if (x<=1) return;
			f[x]++;
		}
		public static void divide(int x,long p){
			if (x<=1) return;
			pow[(int)dv[x]]-=p;
			divide((int)(x/dv[x]),p);
		}
		public static void divideFact(int x){
			if (x<=1) return;
			f[x]--;
		}
		public static long power(long a, long n){
			if (n==0) return 1;
			long res=power(a,n/2);
			res=(res*res)%modulo;
			if ((n%2)==1) res=(res*a)%modulo;
			return res;
		}
		public static long getres(){
			long res=1; int i;
			for (i=f.length-2;i>=1;i--)
			{
				f[i]+=f[i+1];
				multiply(i, f[i]);
			}
			Arrays.fill(f, 0);
			
			for (i=2;i<pow.length;i++)
				res=(res*(power(i,pow[i])%modulo))%modulo;
			return res;
			
		}
		public static void multiplynCk(int n, int k){
			if ((k==0)||(n==0)||(n==k))return;
			int i;
			if ((n-k)<k) k=n-k;
			multiplyFact(n);
			divideFact(k);divideFact(n-k);
		}
	}
	static long res;
	static void MainMethod()throws Exception{
		n=reader.nextInt(); 
		a=new int[n];
		int i;
		for (i=0;i<n;i++) a[i]=reader.nextInt();
		//for (i=0;i<n;i++) a[i]=100;//=reader.nextInt();
		BigCal.init((n*1002));
		int total=a[0],k;
		for (i=1;i<a.length;i++){
			k=total+a[i]-1;
			BigCal.multiplynCk(k,total);
			total+=a[i];
		}
		res=BigCal.getres(); 
		printer.println(res);
	}
	public static void main(String[] args)throws Exception{
		MainMethod();
		printer.close();
	}
	static void halt(){
		printer.close();
		System.exit(0);
	}
	static PrintWriter printer=new PrintWriter(new OutputStreamWriter(System.out));
	static class reader{
		static BufferedReader bReader=new BufferedReader(new InputStreamReader(System.in));
		static StringTokenizer token=new StringTokenizer("");
		static String readNextLine() throws Exception{
			return bReader.readLine();
		}
		static String next() throws Exception{
			while (token.hasMoreTokens()==false){
				token=new StringTokenizer(bReader.readLine());
			}
			return token.nextToken();
		}
		static int nextInt()throws Exception{
			while (token.hasMoreTokens()==false){
				token=new StringTokenizer(bReader.readLine());
			}
			return Integer.parseInt(token.nextToken());
		}
		static long nextLong()throws Exception{
			while (token.hasMoreTokens()==false){
				token=new StringTokenizer(bReader.readLine());
			}
			return Long.parseLong(token.nextToken());
		}
		static double nextDouble()throws Exception{
			while (token.hasMoreTokens()==false){
				token=new StringTokenizer(bReader.readLine());
			}
			return Double.parseDouble(token.nextToken());
		}
	}
	static class MyMathCompute{
		static long [][] MatrixMultiplyMatrix(long [][] A, long [][] B, long mod) throws Exception{
			int n=A.length, m=B[0].length; 
			int p=A[0].length;
			int i,j,k;
			if (B.length!=p) throw new Exception("invalid matrix input");
			long [][] res=new long [n][m];
			for (i=0;i<n;i++) for (j=0;j<m;j++){
				if (A[i].length!=p) throw new Exception("invalid matrix input");
				res[i][j]=0;
				for (k=0;k<p;k++)
					res[i][j]=(res[i][j]+((A[i][k]*B[k][j])% mod))% mod;
			}
			return res;
		}
		static double [][] MatrixMultiplyMatrix(double [][] A, double [][] B ) throws Exception{
			int n=A.length, m=B[0].length; 
			int p=A[0].length;
			int i,j,k;
			if (B.length!=p) throw new Exception("invalid matrix input");
			double [][] res=new double [n][m];
			for (i=0;i<n;i++) for (j=0;j<m;j++){
				if (A[i].length!=p) throw new Exception("invalid matrix input");
				res[i][j]=0;
				for (k=0;k<p;k++)
					res[i][j]=res[i][j]+(A[i][k]*B[k][j]);
			}
			return res;
		}
		static long [][] MatrixPow(long [][] A,long n, long mod) throws Exception{
			if (n==1) return A;
			long [][] res=MatrixPow(A, n/2, mod);
			res=MatrixMultiplyMatrix(res, res, mod);
			if ((n % 2) == 1) res=MatrixMultiplyMatrix(A,res, mod);		
			return res;
		}
		static double [][] MatrixPow(double [][] A,long n) throws Exception{
			if (n==1) return A;
			double[][] res=MatrixPow(A, n/2);
			res=MatrixMultiplyMatrix(res, res);
			if ((n % 2) == 1) res=MatrixMultiplyMatrix(A,res);		
			return res;
		}
		static long pow(long a,long n,long mod){
			a= a % mod;
			if (n==0) return 1;
			long k=pow(a,n/2,mod);
			if ((n % 2)==0) return ((k*k)%mod);
			else return (((k*k) % mod)*a) % mod;
		}
		static double pow(double a,long n){
			if (n==0) return 1;
			double k=pow(a,n/2);
			if ((n % 2)==0) return (k*k);
			else return (((k*k) )*a) ;
		}
	}
}
