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.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.io.Reader;
import java.io.UnsupportedEncodingException;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.StringTokenizer;
import java.util.TreeMap;

public class C {
	private final static long START_TIME=System.currentTimeMillis();
	private final static boolean LOG_ENABLED=true;
	private final static boolean ONLINE_JUDGE = LOG_ENABLED && (System.getProperty("ONLINE_JUDGE") != null);
	private final static String SYSTEM_ENCODING="utf-8";


	private static class Logger{
		private final PrintWriter logWriter=Util.newPrintWriter(System.err,true);
		private final DecimalFormat df=new DecimalFormat("0.000");
		private void message(String type, String message, Object ... params){
			if(ONLINE_JUDGE){
				return;
			}
			logWriter.printf("["+type+"] "+df.format((System.currentTimeMillis()-START_TIME)/1000.0)+": "+message+"\r\n", params);
		}
		public void debug(String message, Object ... params){
			message("DEBUG", message, params);
		}
	}

	private final static class Util{
		public static PrintWriter newPrintWriter(OutputStream out, boolean autoFlush){
			try {
				return new PrintWriter(new OutputStreamWriter(new BufferedOutputStream(out), SYSTEM_ENCODING),autoFlush);
			} catch (UnsupportedEncodingException e) {
				throw new IllegalStateException(e);
			}
		}
	}

	public final static class FastScanner{
		private BufferedReader reader;
		private StringTokenizer currentTokenizer;
		public FastScanner(Reader reader) {
			if(reader instanceof BufferedReader){
				this.reader=(BufferedReader) reader;
			}else{
				this.reader=new BufferedReader(reader);
			}
		}

		public String next(){
			if(currentTokenizer==null || !currentTokenizer.hasMoreTokens()){
				try {
					currentTokenizer=new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new IllegalStateException(e);
				}
			}

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

		public long nextLong(){
			return Long.parseLong(next());
		}

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

	}

	private final static Logger log=new Logger();
	private final BufferedReader reader;
	private final FastScanner in;
	private final PrintWriter out=Util.newPrintWriter(System.out,false);

	public C(BufferedReader reader){
		this.reader=reader;
		in=new FastScanner(this.reader);
	}

	public static void main(String[] args) throws IOException {
		log.debug("Started");
		try{
			new C(new BufferedReader(new InputStreamReader(System.in, SYSTEM_ENCODING))).run();
		}finally{
			log.debug("Stopped");
		}
	}

	void run(){
		solve();
		out.flush(); 
	}

	private void solve(){
		int n=in.nextInt();
		List<Integer> colors=new ArrayList<>();
		int sum=0;
		for(int i=0;i<n;i++){
			int colorCount = in.nextInt();
			
			if(i==(n-1)||i==(n-2)){
				colorCount--;
			}
			if(colorCount>1){
				colors.add(colorCount);
			}
			sum+=colorCount;
		}
		if(n==1){
			out.println(1);
		}
		Map<Integer, Integer> sumFact = getFact(sum);
		for(Integer i:colors){
			divide(sumFact,getFact(i));
		}
		long result=1;
		for(Entry<Integer, Integer> e:sumFact.entrySet()){
			Integer num = e.getKey();
			Integer pow = e.getValue();
			for(int i=0;i<pow;i++){
				result*=num;
				result%= 1000000007;
			}
		}
		out.println(result);
	}
	private void divide(Map<Integer, Integer> result,	Map<Integer, Integer> iMap) {
		for(Entry<Integer, Integer> e:iMap.entrySet()){
			Integer count = result.get(e.getKey());
			if(count==null){
				count=0;
			}
			count-=e.getValue();
			result.put(e.getKey(), count);
		}
	}

	private Map<Integer, Integer> getFact(int sum) {
		Map<Integer, Integer> result=new HashMap<Integer, Integer>();
		for(int i=2;i<=sum;i++){
			Map<Integer, Integer> iMap = factor(i);
			multiply(result, iMap);
		}
		return result;
	}
	private void multiply(Map<Integer, Integer> result, Map<Integer, Integer> iMap) {
		for(Entry<Integer, Integer> e:iMap.entrySet()){
			Integer count = result.get(e.getKey());
			if(count==null){
				count=0;
			}
			count+=e.getValue();
			result.put(e.getKey(), count);
		}
	}
	Map<Integer, Map<Integer, Integer>> cache=new HashMap<>(); 
	Map<Integer, Integer> factor(int param){
		Map<Integer, Integer> cachedResult = cache.get(param);
		if(cachedResult!=null){
			return cachedResult;
		}
		Map<Integer, Integer> result=new HashMap<>();
		int number = param;
		int max=(int) (Math.sqrt(number)+1);
		for(int i=2;i<max;i++){
			if(number==1){
				break;
			}
			int iCount = 0;
			while(number%i==0){
				iCount++;
				number/=i;
			}
			if(iCount>0){
				result.put(i, iCount);
			}
		}
		if(number!=1){
			result.put(number, 1);
		}
		cache.put(param, result);
		return result;
	}

}
//-------------------------------