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.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.Arrays;
import java.util.StringTokenizer;


public class Main {

    static final int mod = (int)1e9 + 7;
    static int k, n, afterBalls[], c[];
    static long[][] memo;
    
    static long dp(int color, int pos)
    {
        if(color == k)
            return pos == n ? 1 : 0;
        if(pos == n)
            return 0;
        if(memo[color][pos] != -1)
            return memo[color][pos];
        
        long place = 0, skip = dp(color, pos + 1);
        if(n - pos - 1 <= afterBalls[color])
            place = (dp(color + 1, pos + 1) * nCr(pos - (n - afterBalls[color] - c[color]), c[color] - 1).mod(BigInteger.valueOf(mod)).intValue())%mod;
        return memo[color][pos] = (place + skip)%mod;
    }
    

    static BigInteger m[][];      //may need BigInteger
    
    static BigInteger nCr(int n, int k)
    {
        if(k == 0)
            return BigInteger.ONE;
        if(m[n][k] != null)
            return m[n][k];
        if(n - k < k)
            return m[n][k] = nCr(n, n - k);
        
        return m[n][k] = nCr(n - 1, k - 1).multiply(BigInteger.valueOf(n)).divide(BigInteger.valueOf(k));
    }
    
    public static void main(String[] args) throws IOException 
    {
        
        Scanner sc = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);

        k = sc.nextInt();
        afterBalls = new int[k]; c = new int[k];
        for(int i = 0; i < k; i++)
            n += c[i] = sc.nextInt();
        afterBalls[0] = n - c[0];
        for(int i = 1; i < k; i++)
            afterBalls[i] = afterBalls[i-1] - c[i];
        
        memo = new long[k][n]; m = new BigInteger[n + 1][n + 1];
        for(int i = 0; i < k; i++)
            Arrays.fill(memo[i], -1);

        System.out.println(dp(0, 0));
        out.flush();
    }

    
    static class Scanner 
    {
        StringTokenizer st;
        BufferedReader br;

        public Scanner(InputStream s){  br = new BufferedReader(new InputStreamReader(s));}

        public String next() throws IOException 
        {
            while (st == null || !st.hasMoreTokens()) 
                st = new StringTokenizer(br.readLine());
            return st.nextToken();
        }

        public int nextInt() throws IOException {return Integer.parseInt(next());}
        
        public long nextLong() throws IOException {return Long.parseLong(next());}

        public String nextLine() throws IOException {return br.readLine();}
        
        public double nextDouble() throws IOException
        {
            String x = next();
            StringBuilder sb = new StringBuilder("0");
            double res = 0, f = 1;
            boolean dec = false, neg = false;
            int start = 0;
            if(x.charAt(0) == '-')
            {
                neg = true;
                start++;
            }
            for(int i = start; i < x.length(); i++)
                if(x.charAt(i) == '.')
                {
                    res = Long.parseLong(sb.toString());
                    sb = new StringBuilder("0");
                    dec = true;
                }
                else
                {
                    sb.append(x.charAt(i));
                    if(dec)
                        f *= 10;
                }
            res += Long.parseLong(sb.toString()) / f;
            return res * (neg?-1:1);
        }
        
        public boolean ready() throws IOException {return br.ready();}

        int countTokens() throws IOException
        {
            st = new StringTokenizer(br.readLine());
            return st.countTokens();
        }
    }
}