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.io.InputStream;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.InputMismatchException;
import java.util.NoSuchElementException;
import java.math.BigInteger;

public class Main{

static PrintWriter out;
static InputReader ir;

static void solve(){
 int n=ir.nextInt();
 int[] a=ir.nextIntArray(n);
 int tot=0;
 for(int val : a){
  tot+=val;
 }
 long MOD=(long)1e9+7;
 Mod mm=new Mod(1111,MOD);
 long ans=1;
 for(int i=n-1;i>=0;i--){
  ans*=mm.comb(tot-1,a[i]-1);
  ans%=MOD;
  tot-=a[i];
 }
 out.println(ans);
}

static class Mod{

 public static long MOD;
 public static int MAX;
 private long[] fact,factInv;

 public Mod(int MAX,long MOD){
  this.MAX=MAX;
  this.MOD=MOD;
  fact=factArray();
  factInv=factInverseArray();
 }

 public static long gcd(long a,long b){
  if(b==0) return a;
  return gcd(b,a%b);
 }

 public static long lcm(long a,long b){
  return a/gcd(a,b)*b;
 }

 public long mod_inverse(long a){
  long[] ret=extendedgcd(a,MOD);
  return (MOD+ret[0]%MOD)%MOD;
 }

 public static long[] extendedgcd(long a,long b){
  long[] ret=new long[3];
  ret[2]=_extendedgcd(a,b,ret);
  return ret;
 }

 private static long _extendedgcd(long a,long b,long[] x){
  long g=a;
  x[0]=1;
  x[1]=0;
  if(b!=0){
   g=_extendedgcd(b,a%b,x);
   long temp=x[0]; x[0]=x[1]; x[1]=temp;
   x[1]-=(a/b)*x[0];
  }
  return g;
 }

 private long[] factArray(){
  long[] ret=new long[MAX+1];
  ret[0]=1%MOD;
  for(int i=1;i<=MAX;i++){
   ret[i]=ret[i-1]*i;
   ret[i]%=MOD;
  }
  return ret;
 }

 private long[] factInverseArray(){
  long[] ret=new long[MAX+1];
  ret[0]=1;
  for(int i=1;i<=MAX;i++){
   ret[i]=ret[i-1]*mod_inverse(i)%MOD;
  }
  return ret;
 }

 public long comb(int n,int m){
  long ret=fact[n];
  ret*=factInv[m];
  ret%=MOD;
  ret*=factInv[n-m];
  ret%=MOD;
  return ret;
 }
}

public static void main(String[] args) throws Exception{
 ir=new InputReader(System.in);
 out=new PrintWriter(System.out);
 solve();
 out.flush();
}

static class InputReader {
 private InputStream in;
 private byte[] buffer=new byte[1024];
 private int curbuf;
 private int lenbuf;

 public InputReader(InputStream in) {this.in=in; this.curbuf=this.lenbuf=0;}
 
 public boolean hasNextByte() {
  if(curbuf>=lenbuf){
   curbuf= 0;
   try{
    lenbuf=in.read(buffer);
   }catch(IOException e) {
    throw new InputMismatchException();
   }
   if(lenbuf<=0) return false;
  }
  return true;
 }

 private int readByte(){if(hasNextByte()) return buffer[curbuf++]; else return -1;}
 
 private boolean isSpaceChar(int c){return !(c>=33&&c<=126);}
 
 private void skip(){while(hasNextByte()&&isSpaceChar(buffer[curbuf])) curbuf++;}
 
 public boolean hasNext(){skip(); return hasNextByte();}
 
 public String next(){
  if(!hasNext()) throw new NoSuchElementException();
  StringBuilder sb=new StringBuilder();
  int b=readByte();
  while(!isSpaceChar(b)){
   sb.appendCodePoint(b);
   b=readByte();
  }
  return sb.toString();
 }
 
 public int nextInt() {
  if(!hasNext()) throw new NoSuchElementException();
  int c=readByte();
  while (isSpaceChar(c)) c=readByte();
  boolean minus=false;
  if (c=='-') {
   minus=true;
   c=readByte();
  }
  int res=0;
  do{
   if(c<'0'||c>'9') throw new InputMismatchException();
   res=res*10+c-'0';
   c=readByte();
  }while(!isSpaceChar(c));
  return (minus)?-res:res;
 }
 
 public long nextLong() {
  if(!hasNext()) throw new NoSuchElementException();
  int c=readByte();
  while (isSpaceChar(c)) c=readByte();
  boolean minus=false;
  if (c=='-') {
   minus=true;
   c=readByte();
  }
  long res = 0;
  do{
   if(c<'0'||c>'9') throw new InputMismatchException();
   res=res*10+c-'0';
   c=readByte();
  }while(!isSpaceChar(c));
  return (minus)?-res:res;
 }

 public double nextDouble(){return Double.parseDouble(next());}

 public BigInteger nextBigInteger(){return new BigInteger(next());}

 public int[] nextIntArray(int n){
  int[] a=new int[n];
  for(int i=0;i<n;i++) a[i]=nextInt();
  return a;
 }

 public long[] nextLongArray(int n){
  long[] a=new long[n];
  for(int i=0;i<n;i++) a[i]=nextLong();
  return a;
 }

 public char[][] nextCharMap(int n,int m){
  char[][] map=new char[n][m];
  for(int i=0;i<n;i++) map[i]=next().toCharArray();
  return map;
 }
}
}