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.*;

public class Sol {

	static final boolean stdin = true;
	static final String filename = "";
	static FastScanner br;
	static PrintWriter pw;

	public static void main(String[] args) throws IOException {

		if (stdin) {
			br = new FastScanner();
			pw = new PrintWriter(new OutputStreamWriter(System.out));
		} else {
			br = new FastScanner(filename + ".in");
			pw = new PrintWriter(new FileWriter(filename + ".out"));
		}

		Solver solver = new Solver();
		solver.solve(br, pw);
	}

	static class Solver {
		static long mod = 1000000007;
		static int[] cnts, psum;
		static long[][] c;

		public void solve(FastScanner br, PrintWriter pw) throws IOException {
			int n = br.nextInt();
			c = new long[1001][1001];
			cnts = new int[n];
			psum = new int[n];
			c[0][0] = 1;
			for (int i = 1; i < 1001; i++) {
				c[i][0] = 1;
				for (int j = 1; j < i + 1; j++) {
					c[i][j] = (c[i - 1][j] + c[i - 1][j - 1]) % mod;
				}
			}
			for (int i = 0; i < n; i++) {
				cnts[i] = br.nextInt();
				psum[i] = cnts[i];
				if (i != 0) {
					psum[i] += psum[i - 1];
				}
			}
			pw.println(recur(n));
			pw.close();
		}

		static long recur(int s) {
			if (s == 0) {
				return 1;
			} else {
				//System.out.println((c[psum[s - 1] - 1][cnts[s - 1] - 1]) % mod);
				return (recur(s - 1) * c[psum[s - 1] - 1][cnts[s - 1] - 1]) % mod;
			}
		}

		static long pow(long a, long b) {
			if (b == 0)
				return 1L;
			long val = pow(a, b / 2);
			if (b % 2 == 0)
				return val * val % mod;
			else
				return val * val % mod * a % mod;
		}

	}

	static class Point1 implements Comparable<Point1> {
		int a;
		int b;

		Point1(int a, int b) {
			this.a = a;
			this.b = b;
		}

		@Override
		public int compareTo(Point1 o) {
			return this.a - o.a;
		}

	}

	static class Point2 implements Comparable<Point2> {
		String a;
		int b;

		Point2(String a, int b) {
			this.a = a;
			this.b = b;
		}

		@Override
		public int compareTo(Point2 o) {
			if (this.a.equals(o.a))
				return 0;
			return -this.b + o.b;
		}

	}

	static class Dsu {
		int n;
		int[] parent;
		int[] rank;

		public Dsu(int n) {
			this.n = n;
			parent = new int[n];
			rank = new int[n];
		}

		public void createSet() {
			for (int i = 0; i < n; i++) {
				parent[i] = i;
				rank[i] = 0;
			}
		}

		public int findParent(int x) {
			if (parent[x] == x)
				return x;
			parent[x] = findParent(parent[x]);
			return parent[x];
		}

		public void mergeSet(int a, int b) {
			int pa = findParent(a);
			int pb = findParent(b);

			if (pa == pb)
				return;

			if (rank[pa] > rank[pb]) {
				parent[pb] = pa;
			} else if (rank[pa] < rank[pb]) {
				parent[pa] = pb;
			} else {
				parent[pb] = pa;
				rank[pa]++;
			}
		}
	}

	public static class FastScanner {
		BufferedReader br;
		StringTokenizer st;

		public FastScanner(String s) {
			try {
				br = new BufferedReader(new FileReader(s));
			} catch (FileNotFoundException e) {
				e.printStackTrace();
			}
		}

		public FastScanner() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		String nextToken() {
			while (st == null || !st.hasMoreElements()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

		int nextInt() {
			return Integer.parseInt(nextToken());
		}

		long nextLong() {
			return Long.parseLong(nextToken());
		}

		double nextDouble() {
			return Double.parseDouble(nextToken());
		}

		ArrayList<Integer>[] nextGraph(int nodes, int edges) {
			ArrayList<Integer>[] adj = new ArrayList[nodes];
			for (int i = 0; i < nodes; i++) {
				adj[i] = new ArrayList<Integer>();
			}
			for (int i = 0; i < edges; i++) {
				int a = nextInt() - 1;
				int b = nextInt() - 1;
				adj[a].add(b);
				adj[b].add(a);
			}
			return adj;
		}
	}
}