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.*;
import java.util.Arrays;
import java.util.StringTokenizer;

public class L {
  static int MOD = 1000000007;

  public static void main(String[] args) throws IOException {
    Reader reader = new Reader();
    reader.initConsoleReading();
    OutputStream outputStream = System.out;
    PrintWriter out = new PrintWriter(outputStream);
    int c[][] = new int[1001][1001];
    for (int i = 0; i <= 1000; i++) {
      c[i][0] = 1;
      c[0][i] = 0;
    }
    c[0][0] = 1;
    for (int i = 1; i <= 1000; i++) {
      for (int j = 1; j <= i; j++) {
        c[i][j] = (c[i - 1][j] + c[i - 1][j - 1]) % MOD;
      }
    }
    int n = reader.nextInt();
    int r = 1;
    int csum = 0;
    int cur = 0;
    for (int i = 1; i <= n; i++) {
      cur = reader.nextInt();
      csum += cur;
      r = (r * c[csum - 1][cur - 1]) % MOD;
    }
    out.println(r);
    out.close();
    reader.dispose();
  }

  /**
   * **********************************Helper Methods Begin
   * Here*********************************************
   */
  private static String reverse(String toRev) {
    return new StringBuilder(toRev).reverse().toString();
  }

  public static class Pair<F extends Comparable<F>, S extends Comparable<S>>
      implements Comparable<Pair<F, S>> {
    static final int prime = 31;
    private F first;
    private S second;

    public Pair(F f, S s) {
      this.first = f;
      this.second = s;
    }

    @Override
    public int hashCode() {
      int result = 1;
      result = prime * result + this.first.hashCode();
      result = prime * result + this.second.hashCode();
      return result;
    }

    @Override
    public boolean equals(Object obj) {
      if (this == obj) return true;
      if (obj == null) return false;
      if (getClass() != obj.getClass()) return false;
      Pair<F, S> s = (Pair<F, S>) obj;
      return this.first.equals(s.first) && this.second.equals(s.second);
    }

    @Override
    public int compareTo(Pair<F, S> p) {
      int c1 = this.first.compareTo(p.first);
      if (c1 == 0) {
        return this.second.compareTo(p.second);
      }
      return c1;
    }
  }

  public static int swap(int a, int b) {
    /*a = Main.swap(b,b=a); goes from left to right*/
    return a;
  }

  public static long swap(long a, long b) {
    /*a = Main.swap(b,b=a); goes from left to right*/
    return a;
  }

  public static boolean next_permutation(int[] p) {
    for (int a = p.length - 2; a >= 0; --a)
      if (p[a] < p[a + 1])
        for (int b = p.length - 1; ; --b)
          if (p[b] > p[a]) {
            int t = p[a];
            p[a] = p[b];
            p[b] = t;
            for (++a, b = p.length - 1; a < b; ++a, --b) {
              t = p[a];
              p[a] = p[b];
              p[b] = t;
            }
            return true;
          }
    return false;
  }

  public static long gcd(long a, long b) {
    if (a < 0) a *= -1;
    if (b < 0) b *= -1;
    return b == 0 ? a : gcd(b, a % b);
  }

  public static class Reader {
    public BufferedReader reader;
    public StringTokenizer tokenizer;

    public Reader() {}

    public Reader initConsoleReading() {
      reader = new BufferedReader(new InputStreamReader(System.in), 32768);
      tokenizer = null;
      return this;
    }

    public Reader initFileReading(String filePath) throws FileNotFoundException {
      reader = new BufferedReader(new FileReader(filePath), 32768);
      tokenizer = null;
      return this;
    }

    public String next() {
      while (tokenizer == null || !tokenizer.hasMoreTokens()) {
        try {
          tokenizer = new StringTokenizer(reader.readLine());
        } catch (IOException e) {
          throw new RuntimeException(e);
        }
      }
      return tokenizer.nextToken();
    }

    public String nextLine() throws IOException {
      return reader.readLine();
    }

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

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

    public void dispose() throws IOException {
      this.reader.close();
    }
  }
  /**
   * **********************************Helper Methods Ends
   * Here*********************************************
   */
}
