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  
    
import java.util.*;
import java.io.*;
import java.math.*;
import java.text.*;
public class Main
{
    static class Reader 
    { 
        private InputStream mIs;private byte[] buf = new byte[1024];private int curChar,numChars;public Reader() { this(System.in); }public Reader(InputStream is) { mIs = is;} 
        public int read() {if (numChars == -1) throw new InputMismatchException();if (curChar >= numChars) {curChar = 0;try { numChars = mIs.read(buf);} catch (IOException e) { throw new InputMismatchException();}if (numChars <= 0) return -1; }return buf[curChar++];} 
        public String nextLine(){int c = read();while (isSpaceChar(c)) c = read();StringBuilder res = new StringBuilder();do {res.appendCodePoint(c);c = read();}while (!isEndOfLine(c));return res.toString() ;} 
        public String s(){int c = read();while (isSpaceChar(c)) c = read();StringBuilder res = new StringBuilder();do {res.appendCodePoint(c);c = read();}while (!isSpaceChar(c));return res.toString();} 
        public long l(){int c = read();while (isSpaceChar(c)) c = read();int sgn = 1;if (c == '-') { sgn = -1 ; c = read() ; }long res = 0; do{ if (c < '0' || c > '9') throw new InputMismatchException();res *= 10 ; res += c - '0' ; c = read();}while(!isSpaceChar(c));return res * sgn;} 
        public int i(){int c = read() ;while (isSpaceChar(c)) c = read();int sgn = 1;if (c == '-') { sgn = -1 ; c = read() ; }int res = 0;do{if (c < '0' || c > '9') throw new InputMismatchException();res *= 10 ; res += c - '0' ; c = read() ;}while(!isSpaceChar(c));return res * sgn;} 
        public double d() throws IOException {return Double.parseDouble(s()) ;}
        public boolean isSpaceChar(int c) { return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1; } 
        public boolean isEndOfLine(int c) { return c == '\n' || c == '\r' || c == -1; } 
        public int[] arr(int n){int[] ret = new int[n];for (int i = 0; i < n; i++) {ret[i] = i();}return ret;}
    }
    
    
 
           //       |----|       /\      |    |   -----   |
           //       |   /       /  \     |    |     |     |
           //       |--/       /----\    |----|     |     |
           //       |   \     /      \   |    |     |     |
           //       |    \   /        \  |    |   -----   -------

    static long fact[];
    public static long inv(long x)
    {
        long r,y;
        for(r=1,y=mod-2;y>0;x=(x*x)%mod,y/=2)
            if(y%2==1)
                r=r*x%mod;
        return r;
    }
    public static  long nCr(int n, int m)
    {
        return (fact[n] *inv(fact[m])%mod *inv(fact[n-m])%mod)%mod ;
    }
    static int n,arr[],sum;
    static int presum[];
    static long mod=1000000007;
    static long cache[][];
    public static long dp(int balls,int color)
    {
        if(balls==sum)
        {
            if(color==n)
            return 1;
            return 0;
        }
        if(cache[balls][color]!=-1)
            return cache[balls][color];
        long ans=dp(balls+1,color)%mod;
        if(presum[color+1]<=balls+1)
            ans+=nCr(balls-presum[color],arr[color]-1)*dp(balls+1,color+1)%mod;
        return cache[balls][color]=ans%mod;
    }
    public static void main(String[] args)throws IOException
    {
        PrintWriter out= new PrintWriter(System.out);
        Reader sc=new Reader();
        n=sc.i();
        arr=sc.arr(n);
        for(int i=0;i<n;i++)
            sum+=arr[i];
        
        fact=new long[10000];
        fact[0]=1l;
        for (int i=1;i<10000;i++)
            fact[i]=(fact[i-1]*i)%mod;
            
        presum=new int[n+1];
        for(int i=1;i<=n;i++)
            presum[i]+=presum[i-1]+arr[i-1];
            
        cache=new long[1002][1002];
        for(int i=0;i<1002;i++)
            Arrays.fill(cache[i],-1l);
        out.println(dp(0,0));
        out.flush();
    }
}