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.InputStreamReader;
import java.io.PrintWriter;
import java.util.stream.Collectors;
import java.util.stream.IntStream;

public class Main {

    public static final long MOD = (long) 1e9 + 7;
    public static final int  N = 1002 * 1002;

    private static long[] fact = new long[N];
    private static long[] invFact = new long[N];

    public static void main(String[] args) throws Exception {
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        InputReader inputReader = new InputReader(in);
        PrintWriter out = new PrintWriter(System.out);

        int k = inputReader.getNextInt();
        Integer[] values = IntStream.range(0, k)
                .mapToObj(x -> inputReader.getNextInt())
                .collect(Collectors.toList())
                .toArray(new Integer[k]);

        fact[0] = invFact[0] = 1;

        for (int i = 1; i < N; i++) {
            fact[i] = (fact[i-1] * i) % MOD;
            invFact[i] = exp(fact[i], MOD -2, MOD);
        }

        long sol = 1;
        int len = values[0];

        for (int i = 1; i < k; i++) {
            sol = (sol * comb(len+values[i]-1, values[i]-1)) % MOD;
            len = len + values[i];
        }

        out.println(sol);

        in.close();
        out.close();
    }

    public static final long comb(int n, int k) {
        return (((fact[n] * invFact[k]) % MOD) * invFact[n-k]) % MOD;
    }

    public static final long exp(long b, long e, long mod) {
        long sol = 1;

        while (e > 0) {
            if ((e & 1) > 0) {
                sol = (sol * b) % mod;
            }

            b = (b * b) % mod;
            e = e >> 1;
        }

        return sol;
    }

    public static class InputReader {

        static final String SEPARATOR = " ";

        String[] split;
        int head = 0;
        BufferedReader in;

        public InputReader(BufferedReader in) {
            this.in = in;
        }

        private void fillBuffer() throws RuntimeException {
            try {
                if (split == null || head >= split.length) {
                    head = 0;
                    split = in.readLine().split(SEPARATOR);
                }
            } catch(Exception e) {
                throw new RuntimeException(e);
            }
        }

        public String getNextToken() throws RuntimeException {
            fillBuffer();
            return split[head++];

        }

        public int getNextInt() throws RuntimeException {
            return Integer.parseInt(getNextToken());
        }

        public long getNextLong() throws RuntimeException {
            return Long.parseLong(getNextToken());
        }
    }

    public static <T> String arrayToString(T[] arr) {
        StringBuilder stringBuilder = new StringBuilder();
        for(T x: arr) {
            stringBuilder.append(x + " ");
        }
        return stringBuilder.toString();
    }
}