import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.PriorityQueue;
import java.util.Scanner;

public class SemiDijkstra3 {
	static class Pair<F, S> {
		F first;
		S second;

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

		public F getFirst() {
			return first;
		}

		public S getSecond() {
			return second;
		}
	}

	static class WeightComparator implements Comparator<Pair<Integer, Integer>> {
		public int compare(Pair<Integer, Integer> p1, Pair<Integer, Integer> p2) {
			Integer int1 = p1.getSecond();
			Integer int2 = p2.getSecond();

			return int1.compareTo(int2);
		}
	}

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);

		int n = scan.nextInt();
		int m = scan.nextInt();

		// node -> set of chidren
		// first element in pair is the next node, second is the weight
		HashMap<Integer, HashSet<Pair<Integer, Integer>>> graph = new HashMap<>();
		int[] distance = new int[n];

		HashSet<Integer> notVisited = new HashSet<>();

		// Fill with initial values.
		for (int i = 0; i < n; i++) {
			distance[i] = Integer.MAX_VALUE;
			notVisited.add(new Integer(i + 1));
		}

		// Set up graph.
		while (scan.hasNextInt()) {
			int a = scan.nextInt();
			int b = scan.nextInt();
			int w = scan.nextInt();

			Integer A = new Integer(a);
			Integer B = new Integer(b);
			Integer W = new Integer(w);

			HashSet<Pair<Integer, Integer>> set = graph.get(A);
			if (set == null) {
				set = new HashSet<Pair<Integer, Integer>>();
			}
			Pair<Integer, Integer> p = new Pair<>(B, W);
			set.add(p);
			graph.put(A, set);

			set = graph.get(B);
			if (set == null) {
				set = new HashSet<Pair<Integer, Integer>>();
			}
			p = new Pair<>(A, W);
			set.add(p);
			graph.put(B, set);
		}

		PriorityQueue<Pair<Integer, Integer>> queue = new PriorityQueue<>(1, new WeightComparator());
		queue.add(new Pair<Integer, Integer>(1, 0));
		distance[0] = 0;
		int[] sourceOfShortestDistance = new int[n];

		boolean shortestPathFound = false;

		while (!queue.isEmpty() && !notVisited.isEmpty()) {
			Pair<Integer, Integer> pair = queue.poll();
			Integer node = pair.getFirst();
			int nodeAsInt = node.intValue();

			if (nodeAsInt == n) {
				shortestPathFound = true;
				int source = sourceOfShortestDistance[n-1];
				ArrayList<Integer> list = new ArrayList<>();
				list.add(n);
				while (source != 1) {
					list.add(new Integer(source));
					source = sourceOfShortestDistance[source-1];
				}
				list.add(1);

				StringBuilder builder = new StringBuilder();

				for (int i = list.size() - 1; i >= 0; i--) {
					builder.append(list.get(i) + " ");
				}
				System.out.print(builder.toString());
				break;
			}

			// Add node's children and update distance.
			if (graph.get(node) != null) {
				Iterator<Pair<Integer, Integer>> itr = graph.get(node).iterator();
				while (itr.hasNext()) {
					Pair<Integer, Integer> edge = itr.next();
				 	Integer i = edge.getFirst();
				 	Integer w = edge.getSecond();

				 	int nextNode = i.intValue();
				 	int wAsInt = w.intValue();

					if (notVisited.contains(nextNode)) {
						int thisDistance = distance[nodeAsInt - 1] + wAsInt;

						if (distance[nextNode - 1] > thisDistance) {
							distance[nextNode - 1] = thisDistance;
							sourceOfShortestDistance[nextNode - 1] = nodeAsInt;
						}

						// // Add to queue.
						queue.add(new Pair<Integer, Integer>(nextNode, distance[nextNode - 1]));
					}
				}
			}

			notVisited.remove(node);
		}
		if (!shortestPathFound) {
			System.out.print(-1);
		}

		scan.close();
	}
}


//
//  Created by x4150
//  Copyright (c) 2015 x4150. All rights reserved.
//
//#define DEBUG

#include <algorithm>
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <complex>
#include <cassert>
#include <cstdlib>
#include <cstdio>
#include <bitset>
#include <vector>
#include <string>
#include <cmath>
#include <ctime>
#include <queue>
#include <list>
#include <map>
#include <set>

using namespace std;

typedef long long ll;

ll power(ll n, ll e, int m)
{
    ll ans = 1;
	while(e)
	{
		if (e&1)
			ans = (ans * n) % m;
		n = (n * n) % m;
		e >>= 1;
	}
	return ans;
}

ll factorial(int m, int mod)
{
	ll ans = 1;
	for (int i = 2; i <= m; i++)
		ans = (ans * i) % mod;
	return ans;
}

int main(int argc, char* argv[])
{
    #ifdef DEBUG
        freopen("in", "r", stdin);
        if (argc > 1)
        	freopen("out", "w", stdout);
    #endif

    int n;
    cin >> n;

    int arr[n];
    for (int i = 0; i < n; i++)
    	cin >> arr[i];

    if (n == 1)
    {
    	return -1;
    }

    int num = 0;
    for (int i = 0; i < n; i++)
    	num += arr[i];

    const int mod = 1000000007;

    ll p1 = factorial(num, mod);
    ll p2 = 1;
    for (int i = 0; i < n; i++)
    	p2 = (p2 * factorial(arr[i], mod)) % mod;

	ll ans = (p1 * power(p2, mod - 2, mod)) % mod;
	if (ans < 0)
		ans += mod;

	cout << ans << endl;

    #ifdef DEBUG
        fclose(stdout);
    #endif
    return 0;
}


#include <stdio.h>
#include <iostream>
#include <stdio.h>
#include <iostream>
#include <string.h>
#define maxx 1010

using namespace std;

int main(){
    long long  s[maxx][maxx]={0};
    int t;
    int a=1;
    int q;
    long long  ans=1;
    for(int i=0;i<maxx;i++)
        s[i][0]=1;
    for(int i=1;i<maxx;i++)
        for(int j=1;j<maxx;j++)
        s[i][j]=(s[i][j-1]+s[i-1][j])%1000000007;
    cin>>t;
    for(int i=0;i<t;i++){
        cin>>q;
        ans=(ans*s[a][q-1])%1000000007;
        a+=q;
    }
    cout<<ans;

}


#include <stdio.h>
#include <iostream>
#include <string.h>
using namespace std;
int main(){
    __int64  dp[1050][1050]={0};
    __int64  num[1050]={0};
    int t,k;
    int sum;
    //int num;
    __int64  zuhe=1;
    while(cin>>t)
    {
    	sum=0;
    	zuhe=1;
    	for(int i=0;i<t;i++){
            cin>>num[i];
            sum=sum+num[i];
        }
    	for(int i=0;i<1050;i++) dp[i][0]=1;
        for(int i=1;i<1050;i++)
            for(int j=1;j<1050;j++)
                dp[i][j]=(dp[i][j-1]+dp[i-1][j])%1000000007;  //把j个球插入i个空=把j-1个球插入i个空+把i-1个球插入j个空
        /*for(int i=0;i<t;i++){
            cin>>num;
            zuhe=(zuhe*dp[sum][num-1])%1000000007;
            sum=sum+num;
        }*/
        //sum=sum-1;
        k=t-1;
        while(sum!=0&&k>=0){
            zuhe=(zuhe*dp[sum-1][num[k]-1])%1000000007;
            sum=sum-num[k];
            k--;
        }
        printf("%I64d\n",zuhe);
    }
    return 0;
}


#include <stdio.h>
#include <iostream>
#include <string.h>
using namespace std;
int main(){
    __int64  dp[1050][1050]={0};
    __int64  num[1050]={0};
    int t,k;
    int sum;
    //int num;
    __int64  zuhe=1;
    while(cin>>t)
    {
    	sum=0;
    	zuhe=1;
    	for(int i=0;i<t;i++){
            cin>>num[i];
            sum=sum+num[i];
        }
    	for(int i=0;i<1050;i++) dp[i][0]=1;
        for(int i=1;i<1050;i++)
            for(int j=1;j<1050;j++)
                dp[i][j]=(dp[i][j-1]+dp[i-1][j])%1000000007;  //把j个球插入i个空=把j-1个球插入i个空+把i-1个球插入j个空
        /*for(int i=0;i<t;i++){
            cin>>num;
            zuhe=(zuhe*dp[sum][num-1])%1000000007;
            sum=sum+num;
        }*/
        sum=sum-1;
        k=t-1;
        while(sum!=0){
            zuhe=(zuhe*dp[sum][num[k]-1])%1000000007;
            sum=sum-num[k];
            k--;
        }
        printf("%I64d\n",zuhe);
    }
    return 0;
}


#include <stdio.h>
#include <iostream>
#include <string.h>
using namespace std;
int main(){
    __int64  dp[1050][1050]={0};
    int t;
    int a=1;
    int q;
    __int64  zuhe=1;
    while(cin>>t)
    {
    	for(int i=0;i<1050;i++) dp[i][0]=1;
        for(int i=1;i<1050;i++)
            for(int j=1;j<1050;j++)
                dp[i][j]=(dp[i][j-1]+dp[i-1][j])%1000000007;
        for(int i=0;i<t;i++){
            cin>>q;
            zuhe=(zuhe*dp[a][q-1])%1000000007;
            a=a+q;
        }
        printf("%I64d\n",zuhe);
    }
    return 0;
}


#include <stdio.h>
#include <iostream>
#include <string.h>
using namespace std;
int main(){
    __int64  dp[1050][1050]={0};
    int t;
    int sum;
    int num;
    __int64  zuhe=1;
    while(cin>>t)
    {
    	sum=1;
    	for(int i=0;i<1050;i++) dp[i][0]=1;
        for(int i=1;i<1050;i++)
            for(int j=1;j<1050;j++)
                dp[i][j]=(dp[i][j-1]+dp[i-1][j])%1000000007;  //把j个球插入i个空=把j-1个球插入i个空+把i-1个球插入j个空
        for(int i=0;i<t;i++){
            cin>>num;
            zuhe=(zuhe*dp[sum][num-1])%1000000007;
            sum=sum+num;
        }
        printf("%I64d\n",zuhe);
    }
    return 0;
}


#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <algorithm>
#include <iostream>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <math.h>
using namespace std;
#pragma warning(disable:4996)
typedef long long LL;
const int INF = 1<<30;
/*

*/
const int MOD = 1000000007;
int a[1000 + 10];
LL fact[1000001];

LL MyPow(LL a, LL b)
{
    LL ret = 1;
    while (b)
    {
        if (b & 1)
            ret = ret * a % MOD;
        a = a * a % MOD;
        b >>= 1;
    }
    return ret;
}
LL C(int n, int m)
{
    if (m > n || m < 0) return 0;
    LL a = fact[n], b = fact[n - m] * fact[m] % MOD;
    return a * MyPow(b, MOD - 2) % MOD;//除以一个数，等于乘以这个数的乘法逆元， 然后是在MOD的情况下
}

int main()
{
    fact[0] = 1;
    for (int i = 1; i < 1000001; ++i)
        fact[i] = fact[i - 1] * i %MOD;
    int n;
    scanf("%d", &n);
    for (int i = 0; i < n; ++i)
        scanf("%d", &a[i]);
    int sum = a[0];
    LL ans = 1;
    for (int i = 1; i < n; ++i)
    {
        sum += a[i];
        ans = ans * C(sum - 1, sum - a[i] - 1) % MOD;
    }
    printf("%I64d\n", ans);
    return 0;
}


#include <stdio.h>
#include <iostream>
#include <string.h>
using namespace std;
int main(){
    __int64  dp[1050][1050]={0};
    int t;
    int a=1;
    int q;
    __int64  zuhe=1;
    for(int i=0;i<1050;i++)
        dp[i][0]=1;
    for(int i=1;i<1050;i++)
        for(int j=1;j<1050;j++)
        dp[i][j]=(dp[i][j-1]+dp[i-1][j])%1000000007;
    cin>>t;
    for(int i=0;i<t;i++){
        cin>>q;
        zuhe=(zuhe*dp[a][q-1])%1000000007;
        a+=q;
    }
    printf("%I64d\n",zuhe);
    return 0;
}


#include<iostream>
#include<stdio.h>
#include<algorithm>
using namespace std;
int main()
{
   __int64 sum,zuhe,fenzi,fenmu;
   __int64 a,b,n,num[1050],i,j,k;
   while(scanf("%I64d",&n)!=EOF)
   {
        sum=0;
        for(i=1;i<=n;i++)
        {
           scanf("%I64d",&num[i]);
           sum=sum+num[i];
           //cout<<sum<<endl;
        }
        sum=sum-1;
        //cout<<sum<<endl;
        zuhe=1;
        k=n;
        fenmu=1;
        fenzi=1;
        while(k>0&&sum>0)
        {
             /*if(num[k]==1)
             {
                sum=sum-num[k];
                k--;
             }
             else{*/
                     for(j=sum;j>=sum-num[k]+2;j--)
                     {
                         fenmu=(fenmu*(j%1000000007))%1000000007;
                        // cout<<fenmu<<endl;

                     }
                     for(i=1;i<=num[k]-1;i++) fenzi=(fenzi%1000000007*i%1000000007)%1000000007;
                     //cout<<fenzi<<endl;
                     zuhe=zuhe*(fenmu/fenzi)%1000000007;
                     sum=sum-num[k];
                     //cout<<sum<<endl;
                     //cout<<sum<<endl;
                     k--;
                     fenzi=1;
                     fenmu=1;
             //}
        }
        printf("%I64d\n",zuhe);
   }
   return 0;
}


#include <stdio.h>
#include <iostream>
#include <string.h>
using namespace std;
int main(){
    __int64  dp[1050][1050]={0};
    __int64  num[1050]={0};
    int t,k;
    int sum;
    //int num;
    __int64  zuhe=1;
    while(cin>>t)
    {
    	sum=0;
    	zuhe=1;
    	for(int i=0;i<t;i++){
            cin>>num[i];
            sum=sum+num[i];
        }
    	for(int i=0;i<1050;i++) dp[i][0]=1;
        for(int i=1;i<1050;i++)
            for(int j=1;j<1050;j++)
                dp[i][j]=(dp[i][j-1]+dp[i-1][j])%1000000007;  //把j个球插入i个空=把j-1个球插入i个空+把i-1个球插入j个空
        /*for(int i=0;i<t;i++){
            cin>>num;
            zuhe=(zuhe*dp[sum][num-1])%1000000007;
            sum=sum+num;
        }*/
        sum=sum-1;
        k=t;
        while(sum!=0){
            zuhe=(zuhe*dp[sum][num[k]-1])%1000000007;
            sum=sum-num[k];
            k--;
        }
        printf("%I64d\n",zuhe);
    }
    return 0;
}


#include <stdio.h>
#include <iostream>
#include <string.h>
#define maxx 1010
using namespace std;
int main(){
    __int64  s[maxx][maxx]={0};
    int t;
    int a=1;
    int q;
    __int64  zuhe=1;
    for(int i=0;i<maxx;i++)
        s[i][0]=1;
    for(int i=1;i<maxx;i++)
        for(int j=1;j<maxx;j++)
        s[i][j]=(s[i][j-1]+s[i-1][j])%1000000007;
    cin>>t;
    for(int i=0;i<t;i++){
        cin>>q;
        zuhe=(zuhe*s[a][q-1])%1000000007;
        a+=q;
    }
    printf("%I64d\n",zuhe);

}


#include <stdio.h>
#include <iostream>
#include <string.h>
#define maxx 1010

using namespace std;

int main(){
    long long  s[maxx][maxx]={0};
    int t;
    int a=1;
    int q;
    long long  ans=1;
    for(int i=0;i<maxx;i++)
        s[i][0]=1;
    for(int i=1;i<maxx;i++)
        for(int j=1;j<maxx;j++)
        s[i][j]=(s[i][j-1]+s[i-1][j])%1000000007;
    cin>>t;
    for(int i=0;i<t;i++){
        cin>>q;
        ans=(ans*s[a][q-1])%1000000007;
        a+=q;
    }
    cout<<ans;

}


#include <stdio.h>
#include <iostream>
#include <string.h>
using namespace std;
int main(){
    __int64  dp[1050][1050]={0};
    int t;
    int a=1;
    int q;
    __int64  zuhe=1;
    cin>>t;
    for(int i=0;i<1050;i++)
        dp[i][0]=1;
    for(int i=1;i<1050;i++)
        for(int j=1;j<1050;j++)
        dp[i][j]=(dp[i][j-1]+dp[i-1][j])%1000000007;
    //cin>>t;
    for(int i=0;i<t;i++){
        cin>>q;
        zuhe=(zuhe*dp[a][q-1])%1000000007;
        a=a+q;
    }
    printf("%I64d\n",zuhe);
    return 0;
}


#include <stdio.h>
#include <iostream>
#include <string.h>
using namespace std;
int main(){
    __int64  dp[1050][1050]={0};
    __int64  num[1050]={0};
    int t,k;
    int sum;
    __int64  zuhe=1;
    while(cin>>t)
    {
    	sum=1;
    	zuhe=1;
    	for(int i=0;i<1050;i++) dp[i][0]=1;
        for(int i=1;i<1050;i++)
            for(int j=1;j<1050;j++)
                dp[i][j]=(dp[i-1][j-1]+dp[i-1][j])%1000000007;  //把j个球插入i个空=把j-1个球插入i个空+把i-1个球插入j个空
        for(int i=0;i<t;i++){
            cin>>num[i];
            zuhe=(zuhe*dp[sum][num[i]-1])%1000000007;
            sum=sum+num[i];
        }
        printf("%I64d\n",zuhe);
    }
    return 0;
}


#include <stdio.h>
#include <iostream>
#include <string.h>
using namespace std;
int main(){
    __int64  dp[1050][1050]={0};
    __int64  num[1050]={0};
    int t,k;
    int sum;
    //int num;
    __int64  zuhe=1;
    while(cin>>t)
    {
    	sum=1;
    	zuhe=1;
    	for(int i=0;i<1050;i++) dp[i][0]=1;
        for(int i=1;i<1050;i++)
            for(int j=1;j<1050;j++)
                dp[i][j]=(dp[i][j-1]+dp[i-1][j])%1000000007;  //把j个球插入i个空=把j-1个球插入i个空+把i-1个球插入j个空
        for(int i=0;i<t;i++){
            cin>>num[i];
            zuhe=(zuhe*dp[sum][num[i]-1])%1000000007;
            sum=sum+num[i];
        }
        printf("%I64d\n",zuhe);
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;

long long int mod = 1000000007;
void calper(vector< vector <long long int> >&ncr)
{
	long long int i,j;
	for(i=0;i<1001;i++)
	{
		for(j=0;j<=i;j++)
		{
			if(i==0 || j==0 || i==j)
				ncr[i][j] = 1;
			else if(j==i-1)
				ncr[i][j] = i;
			else
				ncr[i][j] = (ncr[i-1][j] + ncr[i-1][j-1])%mod;
		}
	}
	return;
}
int main()
{
	long long int i,j,k,l,m,n,tot,res;
	tot=0;res=1;
	cin >> k;
	vector< vector <long long int> >ncr(1010,vector<long long int> (1010));
	calper(ncr);
	vector<int>c(k);
	for(i=0;i<k;i++)
		scanf("%d",&c[i]);
	tot+=c[0];
//	for(i=0;i<10;i++)
//		printf("%lld ",ncr[400][i]);
//	printf("\n");
	for(i=1;i<k;i++)
	{
//		printf("%lld %lld\n",ncr[c[i]+tot][tot],ncr[c[i]+tot-1][tot-1]);
//		res = ((res%mod)*(ncr[c[i]+tot][tot]-ncr[c[i]+tot-1][tot-1])%mod)%mod;
		res = (res*((c[i]*ncr[c[i]+tot][tot])/(c[i]+tot)))%mod;
//		printf("%lld\n",res);
		tot=(tot+c[i])%mod;
	}
//	printf("%lld\n",res);
	cout << res << "\n";
	return 0;
}


#include<bits/stdc++.h>
using namespace std;

long long int mod = 1000000007;
void calper(vector< vector <long long int> >&ncr)
{
	long long int i,j;
	for(i=0;i<1001;i++)
	{
		for(j=0;j<=i;j++)
		{
			if(i==0 || j==0 || i==j)
				ncr[i][j] = 1;
			else if(j==i-1)
				ncr[i][j] = i;
			else
				ncr[i][j] = (ncr[i-1][j] + ncr[i-1][j-1])%mod;
		}
	}
	return;
}
int main()
{
	long long int i,j,k,l,m,n,tot,res;
	tot=0;res=1;
	cin >> k;
	vector< vector <long long int> >ncr(1010,vector<long long int> (1010));
	calper(ncr);
	vector<int>c(k);
	for(i=0;i<k;i++)
		scanf("%d",&c[i]);
	tot+=c[0];
	for(i=1;i<k;i++)
	{
		res = (res*ncr[c[i]+tot-1][c[i]-1])%mod;
		tot=(tot+c[i])%mod;
	}
	cout << res << "\n";
	return 0;
}


#include<bits/stdc++.h>
using namespace std;

long long int mod = 1000000007;
void calper(vector< vector <long long int> >&ncr)
{
	long long int i,j;
	for(i=0;i<1000;i++)
	{
		for(j=0;j<=i;j++)
		{
			if(i==0 || j==0)
				ncr[i][j] = 1;
			else if(j==i-1)
				ncr[i][j] = i;
			else
				ncr[i][j] = (ncr[i-1][j] + ncr[i-1][j-1])%mod;
		}
	}
	return;
}
int main()
{
	long long int i,j,k,l,m,n,tot,res;
	tot=0;res=1;
	cin >> k;
	vector< vector <long long int> >ncr(1000,vector<long long int> (1000));
	calper(ncr);
	vector<int>c(k);
	for(i=0;i<k;i++)
		scanf("%d",&c[i]);
	tot+=c[0];
	for(i=1;i<k;i++)
	{
		res = (res*(ncr[c[i]+tot][tot]-ncr[c[i]+tot-1][tot-1]))%mod;
	//	printf("%lld\n",res);
		tot=(tot+c[i])%mod;
	}
//	printf("%lld\n",res);
	cout << res << "\n";
	return 0;
}


#include<iostream>
#include<list>
#include<string>
#include<cstring>
#include<sstream>
#include<cctype>
#include<string.h>
#include<algorithm>
#include<cmath>
#include<stack>
#include<fstream>
#include<cstdlib>
#include<vector>
#include<map>
#include<set>
#include<utility>
#include<iomanip>
#include<queue>
using namespace std;

#define LL long long int
#define uLL unsigned long long int

#define S(a) scanf("%d",&a)
#define S2(a,b) scanf("%d%d",&a,&b)
#define S3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define SLL(a) scanf("%lld",&a)
#define SLL2(a,b) scanf("%lld%lld",&a,&b)
#define SLL3(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)
#define SC(a) scanf("%c",&a)
#define P(a) printf("%d",a)
#define PS(a) printf("%s",a)
#define PLL(a) printf("%lld",a)
#define PCASE(kk) printf("Case %d: ",kk++)
#define PCASENL(kk) printf("Case %d:\n",kk++)
#define NL puts("")

#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
#define pi (2.0*acos(0.0))
#define pii pair<int,int>

template<typename T>inline T POW(T B,T P)
{
    if(P==0) return 1;
    if(P&1) return B*POW(B,P-1);
    else return SQR(POW(B,P/2));
}
template <typename T>inline T BigMod (T b,T p,T m)
{
    if (p == 0) return 1;
    if (p%2 == 0)
    {
        T s = BigMod(b,p/2,m);
        return ((s%m)*(s%m))%m;
    }
    return ((b%m)*(BigMod(b,p-1,m)%m))%m;
}
template <class T> inline T BMOD(T p,T e,T m)
{
    T ret=1;
    while(e)
    {
        if(e&1) ret=(ret*p)%m;
        p=(p*p)%m;
        e>>=1;
    }
    return (T)ret;
}
template <typename T>inline T ModInv (T b,T m)
{
    return BMOD(b,m-2,m);
}
template<typename T>inline T ABS(T a)
{
    if(a<0)return -a;
    else return a;
}
template<typename T>inline T gcd(T a,T b)
{
    if(a<0)return gcd(-a,b);
    if(b<0)return gcd(a,-b);
    return (b==0)?a:gcd(b,a%b);
}
template<typename T>inline T lcm(T a,T b)
{
    if(a<0)return lcm(-a,b);
    if(b<0)return lcm(a,-b);
    return a*(b/gcd(a,b));
}

//for(__typeof(pp.begin()) i=pp.begin(); i!=pp.end(); i++ )

//knight and king move....

#define md (1000000000+7)

//int Dx[]={-2,-1,1,2,1,2,-2,-1};
//int Dy[]={-1,-2,2,1,-2,-1,1,2};
//int dx[]={-1,1,0,0};
//int dy[]={0,0,-1,1};
//int dx[]= {-1,-1,0,0,1,1};
//int dy[]= {-1,0,-1,1,0,1};
//////////////////////////////////////////////////

//#define md  1 000 000 007
LL ncr[1010][1011],arr[1010],fact[1010];
int main(){

//            ncr[1][1]=1;
        for(int i=1;i<=1000;i++)
        {
            ncr[0][i]=1;
            ncr[i][0]=1;
            for(int j=1;j<=i;j++)
            {
                ncr[i][j]=(ncr[i-1][j]+ncr[i-1][j-1])%md;
            }
        }

        fact[0]=1;
        for(int i=1;i<=1000;i++)
        {
            fact[i]=(fact[i-1]*i)%md;
        }

//        cout<<ncr[4][2]<<" "<<ncr[3][2]<<endl;

        int k;
        cin>>k;
        int tot=0;
        for(int i=1;i<=k;i++)
        {
            cin>>arr[i];
            tot+=arr[i];
        }
        LL res=1,room=arr[1],id=1;

        for(int i=2;i<=k;i++)
        {
            room+=(arr[i]-id);

            if(arr[i]-id<=0)
            {
                id++;continue;
            }

            res=(res*ncr[room][i])%md;
            res=(res*fact[i])%md;

            for(int j=1;j<i;j++)
            {
                if(j==1)res=(res*ModInv(fact[arr[j]],(LL)md))%md;
                else res=(res*ModInv(fact[arr[j]-1],(LL)md))%md;
            }
            res=(res*ModInv(fact[arr[i]-1],(LL)md))%md;

            room+=id;
            id++;
        }
        res=(res+md)%md;
        cout<<res<<endl;

        return 0;
}


#include<iostream>
#include<list>
#include<string>
#include<cstring>
#include<sstream>
#include<cctype>
#include<string.h>
#include<algorithm>
#include<cmath>
#include<stack>
#include<fstream>
#include<cstdlib>
#include<vector>
#include<map>
#include<set>
#include<utility>
#include<iomanip>
#include<queue>
using namespace std;

#define LL long long int
#define uLL unsigned long long int

#define S(a) scanf("%d",&a)
#define S2(a,b) scanf("%d%d",&a,&b)
#define S3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define SLL(a) scanf("%lld",&a)
#define SLL2(a,b) scanf("%lld%lld",&a,&b)
#define SLL3(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)
#define SC(a) scanf("%c",&a)
#define P(a) printf("%d",a)
#define PS(a) printf("%s",a)
#define PLL(a) printf("%lld",a)
#define PCASE(kk) printf("Case %d: ",kk++)
#define PCASENL(kk) printf("Case %d:\n",kk++)
#define NL puts("")

#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
#define pi (2.0*acos(0.0))
#define pii pair<int,int>

template<typename T>inline T POW(T B,T P)
{
    if(P==0) return 1;
    if(P&1) return B*POW(B,P-1);
    else return SQR(POW(B,P/2));
}
template <typename T>inline T BigMod (T b,T p,T m)
{
    if (p == 0) return 1;
    if (p%2 == 0)
    {
        T s = BigMod(b,p/2,m);
        return ((s%m)*(s%m))%m;
    }
    return ((b%m)*(BigMod(b,p-1,m)%m))%m;
}
template <class T> inline T BMOD(T p,T e,T m)
{
    T ret=1;
    while(e)
    {
        if(e&1) ret=(ret*p)%m;
        p=(p*p)%m;
        e>>=1;
    }
    return (T)ret;
}
template <typename T>inline T ModInv (T b,T m)
{
    return BigMod(b,m-2,m);
}
template<typename T>inline T ABS(T a)
{
    if(a<0)return -a;
    else return a;
}
template<typename T>inline T gcd(T a,T b)
{
    if(a<0)return gcd(-a,b);
    if(b<0)return gcd(a,-b);
    return (b==0)?a:gcd(b,a%b);
}
template<typename T>inline T lcm(T a,T b)
{
    if(a<0)return lcm(-a,b);
    if(b<0)return lcm(a,-b);
    return a*(b/gcd(a,b));
}

//for(__typeof(pp.begin()) i=pp.begin(); i!=pp.end(); i++ )

//knight and king move....

#define md (1000000000+7)

//int Dx[]={-2,-1,1,2,1,2,-2,-1};
//int Dy[]={-1,-2,2,1,-2,-1,1,2};
//int dx[]={-1,1,0,0};
//int dy[]={0,0,-1,1};
//int dx[]= {-1,-1,0,0,1,1};
//int dy[]= {-1,0,-1,1,0,1};
//////////////////////////////////////////////////

//#define md  1 000 000 007
LL ncr[1010][1011],arr[1010],fact[1010],room[1010];
int main()
{

//            ncr[1][1]=1;
    for(int i=1; i<=1000; i++)
    {
        ncr[0][i]=1;
        ncr[i][0]=1;
        for(int j=1; j<=i; j++)
        {
            ncr[i][j]=(ncr[i-1][j]+ncr[i-1][j-1])%md;
        }
    }

    fact[0]=1;
    for(int i=1; i<=1000; i++)
    {
        fact[i]=(fact[i-1]*i)%md;
    }

//        cout<<ncr[4][2]<<" "<<ncr[3][2]<<endl;

    int k;
    cin>>k;
    int tot=0;
    for(int i=1; i<=k; i++)
    {
        cin>>arr[i];
        tot+=arr[i];
        room[i]=room[i-1]+arr[i];
    }
    LL res=1,N=arr[1];

    for(int i=2; i<=k; i++)
    {
        N+=arr[i];
//        N--;
//        res=(res*ncr[N][i])%md;
        res=(res*fact[N-1])%md;
//        if(i==2)res=(res*ModInv(fact[arr[1]-1],(LL)md))%md;
        res=(res*ModInv(fact[N-arr[i]],(LL)md))%md;
        res=(res*ModInv(fact[arr[i]-1],(LL)md))%md;
    }

//    res=(res*ModInv(fact[arr[1]],(LL)md))%md;
    res=(res+md)%md;
    cout<<res<<endl;

    return 0;
}


#include<iostream>
#include<list>
#include<string>
#include<cstring>
#include<sstream>
#include<cctype>
#include<string.h>
#include<algorithm>
#include<cmath>
#include<stack>
#include<fstream>
#include<cstdlib>
#include<vector>
#include<map>
#include<set>
#include<utility>
#include<iomanip>
#include<queue>
using namespace std;

#define LL long long int
#define uLL unsigned long long int

#define S(a) scanf("%d",&a)
#define S2(a,b) scanf("%d%d",&a,&b)
#define S3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define SLL(a) scanf("%lld",&a)
#define SLL2(a,b) scanf("%lld%lld",&a,&b)
#define SLL3(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)
#define SC(a) scanf("%c",&a)
#define P(a) printf("%d",a)
#define PS(a) printf("%s",a)
#define PLL(a) printf("%lld",a)
#define PCASE(kk) printf("Case %d: ",kk++)
#define PCASENL(kk) printf("Case %d:\n",kk++)
#define NL puts("")

#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
#define pi (2.0*acos(0.0))
#define pii pair<int,int>

template<typename T>inline T POW(T B,T P)
{
    if(P==0) return 1;
    if(P&1) return B*POW(B,P-1);
    else return SQR(POW(B,P/2));
}
template <typename T>inline T BigMod (T b,T p,T m)
{
    if (p == 0) return 1;
    if (p%2 == 0)
    {
        T s = BigMod(b,p/2,m);
        return ((s%m)*(s%m))%m;
    }
    return ((b%m)*(BigMod(b,p-1,m)%m))%m;
}
template <class T> inline T BMOD(T p,T e,T m)
{
    T ret=1;
    while(e)
    {
        if(e&1) ret=(ret*p)%m;
        p=(p*p)%m;
        e>>=1;
    }
    return (T)ret;
}
template <typename T>inline T ModInv (T b,T m)
{
    return BMOD(b,m-2,m);
}
template<typename T>inline T ABS(T a)
{
    if(a<0)return -a;
    else return a;
}
template<typename T>inline T gcd(T a,T b)
{
    if(a<0)return gcd(-a,b);
    if(b<0)return gcd(a,-b);
    return (b==0)?a:gcd(b,a%b);
}
template<typename T>inline T lcm(T a,T b)
{
    if(a<0)return lcm(-a,b);
    if(b<0)return lcm(a,-b);
    return a*(b/gcd(a,b));
}

//for(__typeof(pp.begin()) i=pp.begin(); i!=pp.end(); i++ )

//knight and king move....

#define md (1000000000+7)

//int Dx[]={-2,-1,1,2,1,2,-2,-1};
//int Dy[]={-1,-2,2,1,-2,-1,1,2};
//int dx[]={-1,1,0,0};
//int dy[]={0,0,-1,1};
//int dx[]= {-1,-1,0,0,1,1};
//int dy[]= {-1,0,-1,1,0,1};
//////////////////////////////////////////////////

//#define md  1 000 000 007
LL ncr[1010][1011],arr[1010],fact[1010];
int main(){

//            ncr[1][1]=1;
        for(int i=1;i<=1000;i++)
        {
            ncr[0][i]=1;
            ncr[i][0]=1;
            for(int j=1;j<=i;j++)
            {
                ncr[i][j]=(ncr[i-1][j]+ncr[i-1][j-1])%md;
            }
        }

        fact[0]=1;
        for(int i=1;i<=1000;i++)
        {
            fact[i]=(fact[i-1]*i)%md;
        }

//        cout<<ncr[4][2]<<" "<<ncr[3][2]<<endl;

        int k;
        cin>>k;
        int tot=0;
        for(int i=1;i<=k;i++)
        {
            cin>>arr[i];
            tot+=arr[i];
        }
        LL res=1,room=arr[1],id=1;

        for(int i=2;i<=k;i++)
        {
            room+=(arr[i]-id);

            if(arr[i]-id<=0)
            {
                break;
            }

            res=(res*ncr[room][i])%md;
            res=(res*fact[i])%md;

            for(int j=1;j<i;j++)
            {
                if(j==1)res=(res*ModInv(fact[arr[j]],(LL)md))%md;
                else res=(res*ModInv(fact[arr[j]-1],(LL)md))%md;
            }
            res=(res*ModInv(fact[arr[i]-1],(LL)md))%md;

            room+=id;
            id++;
        }
        cout<<res<<endl;

        return 0;
}


#include<bits/stdc++.h>
using namespace std;

#define M 1000000007

long long SmallC(long long n, long long r, long long MOD)
{
    vector< vector<long long> > C(2,vector<long long> (r+1,0));

    for (long long i=0; i<=n; i++)
    {
        for (long long k=0; k<=r && k<=i; k++)
            if (k==0 || k==i)
                C[i&1][k] = 1;
            else
                C[i&1][k] = (C[(i-1)&1][k-1] + C[(i-1)&1][k])%MOD;
    }
    return C[n&1][r];
}

long long Lucas(long long n, long long m, long long p)
{
    if (n==0 && m==0) return 1;
    long long ni = n % p;
    long long mi = m % p;
    if (mi>ni) return 0;
    return Lucas(n/p, m/p, p) * SmallC(ni, mi, p);
}

long long C(long long n, long long r, long long MOD)
{
    return Lucas(n, r, MOD);
}

int main()
{
    long long n,i,j,val;
    cin>>n;
    long long a[n+1],sum[n+1];
    sum[0]=0;
    for(i=1;i<n+1;i++)
    {
        cin>>a[i];
        sum[i]=sum[i-1]+a[i];
    }
    val=1;
    for(i=2;i<n+1;i++)
    {
        val=val*C(((a[i]-1)+(sum[i-1])), (sum[i-1]), M);
    }
    cout<<val;
return 0;
}


#include<bits/stdc++.h>
using namespace std;

#define M 1000000007

/* This function calculates power of p in n! */
long long countFact(long long n, long long p)
{
    long long k=0;
    while (n>0)
    {
        k+=n/p;
        n/=p;
    }
    return k;
}

/* This function calculates (a^b)%MOD */
long long pow(long long a, long long b, long long MOD)
{
    long long x=1,y=a;
    while(b > 0)
    {
        if(b%2 == 1)
        {
            x=(x*y);
            if(x>MOD) x%=MOD;
        }
        y = (y*y);
        if(y>MOD) y%=MOD;
        b /= 2;
    }
    return x;
}

long long C(long long n, long long r, long long MOD)
{
    long long res = 1;
    vector<bool> isPrime(n+1,1);
    for (long long i=2; i<=n; i++)
        if (isPrime[i])
        {
            for (long long j=2*i; j<=n; j+=i)
                isPrime[j]=0;
            long long k = countFact(n,i) - countFact(r,i) - countFact(n-r,i);
            res = (res * pow(i, k, MOD)) % MOD;
        }
    return res;
}

int main()
{
    long long n,i,j,val;
    cin>>n;
    long long a[n+1],sum[n+1];
    sum[0]=0;
    for(i=1;i<n+1;i++)
    {
        cin>>a[i];
        sum[i]=sum[i-1]+a[i];
    }
    val=1;
    for(i=2;i<n+1;i++)
    {
        val=val*C(((a[i]-1)+(sum[i-1])), (sum[i-1]), M);
    }
    cout<<val;
return 0;
}


#include<bits/stdc++.h>
using namespace std;

#define M 1000000007

/* This function calculates power of p in n! */
long long countFact(long long n, long long p)
{
    long long k=0;
    while (n>0)
    {
        k+=n/p;
        n/=p;
    }
    return k;
}

/* This function calculates (a^b)%MOD */
long long pow(long long a, long long b, long long MOD)
{
    long long x=1,y=a;
    while(b > 0)
    {
        if(b%2 == 1)
        {
            x=(x*y);
            if(x>MOD) x%=MOD;
        }
        y = (y*y);
        if(y>MOD) y%=MOD;
        b /= 2;
    }
    return x;
}

long long C(long long n, long long r, long long MOD)
{
    long long res = 1;
    vector<bool> isPrime(n+1,1);
    for (long long i=2; i<=n; i++)
        if (isPrime[i])
        {
            for (long long j=2*i; j<=n; j+=i)
                isPrime[j]=0;
            long long k = countFact(n,i) - countFact(r,i) - countFact(n-r,i);
            res = (res * pow(i, k, MOD)) % MOD;
        }
    return res;
}

int main()
{
    long long n,i,j,val;
    cin>>n;
    long long a[n+1],sum[n+1];
    sum[0]=0;
    for(i=1;i<n+1;i++)
    {
        cin>>a[i];
        sum[i]=sum[i-1]+a[i];
    }
    val=1;
    for(i=2;i<n+1;i++)
    {
        val=(val*C(((a[i]-1)+(sum[i-1])), (sum[i-1]), M))%M;
    }
    cout<<val;
return 0;
}


#include<bits/stdc++.h>

using namespace std;
#define pb push_back
#define MOD 1000000007
typedef long long LL;
string szero;
vector<int> vt,zt;
map<string, LL > rp;
int n;

string encode(vector<int> vt){
	string res;
	for(int i=0, _n = vt.size(); i<_n; i++){
		stringstream ss;
		ss << vt[i];
		string str = ss.str();
		res =  res + ' '  + str;
	}
	return res;
}

vector<int> decode(string s){
	vector<int> res;
	istringstream in(s);
	int x;
	while(in>> x) res.pb(x);
	return res;
}

LL dp(string s){
	cout << s << endl;
	if( s == szero ) return 1;
	if( rp[s] ) return rp[s];
	vector<int> cur = decode(s);
	LL &res = rp[s];
	for(int i=0; i<n; i++){
		if( cur[i] > 1 ){
			cur[i] --;
			res = (res + dp(encode(cur)) ) % MOD;
			cur[i] ++;
		}
		else if( cur[i]==1 && ( !i|| cur[i-1]==0 ) ){
			cur[i] --;
			res = (res + dp(encode(cur)) ) % MOD;
			cur[i] ++;
		}
	}
	return res;
}

int x;
int main(){
//	freopen("test.in","r",stdin);
	cin >> n;
	for(int i=0; i<n; i++){
		cin >> x;
		vt.pb(x);
		zt.pb(0);
	}
	szero = encode(zt);
	cout << dp(encode(vt));
	return 0;
}


#include<bits/stdc++.h>

using namespace std;
#define pb push_back
#define MOD 1000000007
typedef long long LL;
LL C[2100][2100];
int n;

void init(){
	for(int i=0; i<2001; i++) C[0][i] = C[i][i] = 1;
	for(int i=2; i<2001; i++){
		for(int j=1; j<i; j++){
			C[j][i] = (C[j-1][i-1] + C[j][i-1] )%MOD;
		}
	}
}
int x;
int main(){
//	freopen("test.in","r",stdin);
	init();
	cin >> n;
	LL res = 1;
	cin >> x;
	LL  s = x;
	for(int i=1; i<n; i++){
		cin >> x;
		res = res *C[x-1][s+x-1]%MOD;
		s += x;
	}
	cout << res << endl;
	return 0;
}


#include<bits/stdc++.h>

using namespace std;
#define pb push_back
#define MOD 1000000007
typedef long long LL;
string szero;
vector<int> vt,zt;
map<string, LL > rp;
int n;

string encode(vector<int> vt){
	string res;
	for(int i=0, _n = vt.size(); i<_n; i++){
		stringstream ss;
		ss << vt[i];
		string str = ss.str();
		res =  res + ' '  + str;
	}
	return res;
}

vector<int> decode(string s){
	vector<int> res;
	istringstream in(s);
	int x;
	while(in>> x) res.pb(x);
	return res;
}

LL dp(string s){
	if( s == szero ) return 1;
	if( rp[s] ) return rp[s];
	vector<int> cur = decode(s);
	LL &res = rp[s];
	for(int i=0; i<n; i++){
		if( cur[i] > 1 ){
			cur[i] --;
			res = (res + dp(encode(cur)) ) % MOD;
			cur[i] ++;
		}
		else if( cur[i]==1 && ( !i|| cur[i-1]==0 ) ){
			cur[i] --;
			res = (res + dp(encode(cur)) ) % MOD;
			cur[i] ++;
		}
	}
	return res;
}

int x;
int main(){
//	freopen("test.in","r",stdin);
	cin >> n;
	for(int i=0; i<n; i++){
		cin >> x;
		vt.pb(x);
		zt.pb(0);
	}
	szero = encode(zt);
	cout << dp(encode(vt));
	return 0;
}


#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
char a[101][101];
int main()
{
	int n,t=0,b=0;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		scanf("%s",a[i]);
		int p=1;
		for(int j=1;j<i;j++)
		{
			if(strcmp(a[i],a[j])==0)
				p++;
		}
		if(p>b)
			b=p;
	}
	printf("%d\n",b);
	return 0;
}


#include<stdio.h>
#include <iostream>
using namespace std;
#define m 1000000007
long long int s[1002],c[1002];
long long int p[2002][2002];
int main()
{
	int dummy = 0;
	long long int ans=1;
	long long int k,t;
	s[0]=0;
	cin >> k;
	for(t=1;t<=k;t++)
	{
		cin >> c[t];
		s[t]=s[t-1]+c[t];
	}
	long long int j,n,i;
	for(j=0;j<2002;j++)
		p[j][0]=p[j][j]=1;
	for(n=2;n<=2001;n++)
	{
		for(i=1;i<n;i++)
			p[n][i]=(p[n-1][i-1]+p[n-1][i])%m;
	}
	for(i=2;i<=k;i++)
	{
		j = p[s[i]-1][c[i]-1];
		ans = (ans*j)%m;
	}
	cout<<ans<<endl;
}


#include<iostream>
using namespace std;
int mod=1000000007;
long long n,a[1111],s,ans,t,g;
long long binomial(long long n,long long k)
{
	long long p=1;
	for (int i=0;i<k;i++)
	{
		p*=(n-i);
		p/=(i+1);
		p%=mod;
	}
	p%=mod;
	return p;
}
int main()
{
	cin>>n;
	for (int i=1;i<=n;i++)
	{
		cin>>a[i];
		s+=a[i];
	}
	ans=1;
	for (int i=1;i<=n;i++)
	{
		g=a[i]-1;
		t=0;
		for (int j=1;j<i;j++)
		t+=a[j];
		t+=g;
		ans=ans*binomial(t,g)%mod;
	}
	ans%=mod;
	cout<<ans<<endl;
	return 0;
}


#include<iostream>
#include<algorithm>
#include<cstdio>
using namespace std;
long long mod=1000000007;
long long n,a[1111],s,ans,t,g;
long long c[1111][1111];
int main()
{
	cin>>n;
	for (int i=1;i<=n;i++)
	{
		cin>>a[i];
		s+=a[i];
	}
	ans=1;
	for (int i=0;i<=s;i++) c[i][0]=1;
	for (int i=0;i<=s;i++) c[i][i]=1;
	for (int i=2;i<=s;i++)
	{
		for (int j=1;j<i;j++)
		{
			c[i][j]=(c[i-1][j-1]+c[i-1][j])%mod;
		}
	}
	for (int i=1;i<=n;i++)
	{
		g=a[i]-1;
		t=0;
		for (int j=1;j<i;j++)
		t+=a[j];
		t+=g;
		ans=ans*c[t][g]%mod;
	}
	ans=ans%mod;
	cout<<ans<<endl;
	return 0;
}


#include<iostream>
#include<algorithm>
#include<cstdio>
using namespace std;
long long mod=1000000007;
long long n,a[1111],s,ans,t,g;
long long binomial(long long n,long long k)
{
	long long p=1;
	for (long long i=0;i<k;i++)
	{
		p=p%mod;
		p*=(n-i);
		p/=(i+1);
	}
	p=p%mod;
	return p;
}
int main()
{
	cin>>n;
	for (int i=1;i<=n;i++)
	{
		cin>>a[i];
		s+=a[i];
	}
	ans=1;
	for (int i=1;i<=n;i++)
	{
		g=a[i]-1;
		t=0;
		for (int j=1;j<i;j++)
		t+=a[j];
		t+=g;
		ans=ans*binomial(t,g)%mod;
	}
	ans=ans%mod;
	cout<<ans<<endl;
	return 0;
}


#include<iostream>
#include<algorithm>
#include<cstdio>
using namespace std;
int mod=1000000007;
long long n,a[1111],s,ans,t,g;
long long binomial(long long n,long long k)
{
	long long p=1;
	for (int i=0;i<k;i++)
	{
		p*=(long long)(n-i);
		p/=(long long)(i+1);
		p=p%(long long)mod;
	}
	p=p%(long long)mod;
	return p;
}
int main()
{
	cin>>n;
	for (int i=1;i<=n;i++)
	{
		cin>>a[i];
		s+=a[i];
	}
	ans=1;
	for (int i=1;i<=n;i++)
	{
		g=a[i]-1;
		t=0;
		for (int j=1;j<i;j++)
		t+=a[j];
		t+=g;
		ans=(long long)ans*(long long)binomial(t,g)%(long long)mod;
		if (ans==0) cout<<i<<endl;
	}
	ans=ans%(long long)mod;
	cout<<ans<<endl;
	return 0;
}


#include<iostream>
#include<algorithm>
#include<cstdio>
using namespace std;
long long mod=1000000007;
long long n,a[1111],s,ans,t,g;
long long binomial(long long n,long long k)
{
	long long p=1;
	for (long long i=0;i<k;i++)
	{
		p=p%mod;
		p*=(n-i);
		p/=(i+1);
		cout<<p<<endl;
	}
	p=p%mod;
	return p;
}
int main()
{
	cin>>n;
	for (int i=1;i<=n;i++)
	{
		cin>>a[i];
		s+=a[i];
	}
	ans=1;
	for (int i=1;i<=n;i++)
	{
		g=a[i]-1;
		t=0;
		for (int j=1;j<i;j++)
		t+=a[j];
		t+=g;
		ans=ans*binomial(t,g)%mod;
	}
	ans=ans%mod;
	cout<<ans<<endl;
	return 0;
}


#include<iostream>
using namespace std;
int mod=1000000007;
long long n,a[1111],s,ans,t,g;
long long binomial(long long n,long long k)
{
	long long p=1;
	for (int i=0;i<k;i++)
	{
		p*=(n-i);
		p/=(i+1);
		p=p%mod;
	}
	p=p%mod;
	return p;
}
int main()
{
	cin>>n;
	for (int i=1;i<=n;i++)
	{
		cin>>a[i];
		s+=a[i];
	}
	ans=1;
	for (int i=1;i<=n;i++)
	{
		g=a[i]-1;
		t=0;
		for (int j=1;j<i;j++)
		t+=a[j];
		t+=g;
		ans=ans*binomial(t,g)%mod;
	}
	ans=ans%mod;
	cout<<ans<<endl;
	return 0;
}


#include <cstdio>
#include <cstring>
#include <iostream>

#define MOD 1000000007L

using namespace std;

typedef long long ll;

int N;
ll C[1001][1001];
ll dp[1001];
ll color[1001];

ll combination(int n, int p) {
    if (n == p || p == 0) {
        return C[n][p] = 1;
    }
    if (C[n][p] != -1) {
        return C[n][p];
    }
    else {
        ll ans = combination(n-1, p) % MOD;
        ans = ans + (combination(n-1, p-1) % MOD);
        return C[n][p] = ans % MOD;
    }
}

ll solve(int k) {
    if (k == 1) {
        return 1;
    }
    else if (dp[k] != -1) {
        return dp[k];
    }
    else {
        ll sum = 0;
        for (int i=1 ; i<=k ; i++) {
            sum += color[i];
        }
        sum--;
        ll ans = combination(sum, color[k] - 1);
        ans *= solve(k - 1);
        ans %= MOD;
        return dp[k] = ans;
    }
}

int main() {
    scanf("%d\n", &N);
    for (int i=1 ; i<=N ; i++) {
        cin >> color[i];
    }

    memset(dp, -1, sizeof dp);
    memset(C, -1, sizeof C);
    ll ans = solve(N);
    cout << ans << endl;
}


#include <cstdio>
#include <cstdlib>
#include <iostream>

#define MOD 1000000007L

using namespace std;

typedef long long ll;

int N;
ll C[1001][1001];
ll dp[1001];
ll color[1001];

ll combination(int n, int p) {
    if (n == p || p == 0) {
        return C[n][p] = 1;
    }
    if (C[n][p] != -1) {
        return C[n][p];
    }
    else {
        ll ans = combination(n-1, p) % MOD;
        ans = ans + (combination(n-1, p-1) % MOD);
        return C[n][p] = ans % MOD;
    }
}

ll solve(int k) {
    if (k == 1) {
        return 1;
    }
    else if (dp[k] != -1) {
        return dp[k];
    }
    else {
        ll sum = 0;
        for (int i=1 ; i<=k ; i++) {
            sum += color[i];
        }
        sum--;
        ll ans = combination(sum, color[k] - 1);
        ans *= solve(k - 1);
        ans %= MOD;
        return dp[k] = ans;
    }
}

int main() {
    scanf("%d\n", &N);
    for (int i=1 ; i<=N ; i++) {
        cin >> color[i];
    }

    memset(dp, -1, sizeof dp);
    memset(C, -1, sizeof C);
    ll ans = solve(N);
    cout << ans << endl;
}


#include <cstdio>
#include <vector>
#include <iostream>

#define MOD 1000000007L

using namespace std;

typedef long long ll;

int N;
ll C[1001][1001];
ll dp[1001];
ll color[1001];

ll combination(int n, int p) {
    if (n == p || p == 0) {
        return C[n][p] = 1;
    }
    if (C[n][p] != -1) {
        return C[n][p];
    }
    else {
        ll ans = combination(n-1, p) % MOD;
        ans = ans + (combination(n-1, p-1) % MOD);
        return C[n][p] = ans % MOD;
    }
}

ll solve(int k) {
    if (k == 1) {
        return 1;
    }
    else if (dp[k] != -1) {
        return dp[k];
    }
    else {
        ll sum = 0;
        for (int i=1 ; i<=k ; i++) {
            sum += color[i];
        }
        sum--;
        ll ans = combination(sum, color[k] - 1);
        ans *= solve(k - 1);
        ans %= MOD;
        return dp[k] = ans;
    }
}

int main() {
    scanf("%d\n", &N);
    for (int i=1 ; i<=N ; i++) {
        cin >> color[i];
    }

    memset(dp, -1, sizeof dp);
    memset(C, -1, sizeof C);
    ll ans = solve(N);
    cout << ans << endl;
}


/*////////////////////////////////////
       Harsh  Rumalwala
       ---- hr1212 ----
////////////////////////////////////*/

#include <list>
#include <deque>
#include <stack>
#include <bitset>
#include <functional>
#include <utility>
#include <sstream>
#include <iomanip>
#include <ctime>
#include <algorithm>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <stdio.h>
#include <cstdlib>
#include <cctype>
#include <cmath>
#include <numeric>
#include <valarray>
#include <complex>
#include <string.h>
#include <climits>

using namespace std;

const int dr[]={0,-1,0,1,-1,1, 1,-1};
const int dc[]={1,0,-1,0, 1,1,-1,-1};

typedef long long ll;
typedef long long unsigned ull;
typedef long double ld;
typedef unsigned short us;
typedef unsigned int uint;
typedef unsigned char uchar;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef pair<int,pii> piii;
typedef map<int,int> mi;
typedef map<string,int> msi;

#define ss(a) scanf("%s",a)
#define si(a) scanf("%d",&a)
#define sc(a) scanf("%c",&a)
#define sii(a,b) scanf("%d %d",&a,&b)
#define siii(a,b,c) scanf("%d %d %d",&a,&b,&c)
#define sll(a) scanf("%I64d",&a)
#define ill(a) scanf("%lld",&a)
#define pi(a) printf("%d\n",a)
#define op(a) printf("%d ",a)
#define ps(a) printf("%s\n",a)
#define ppi(a,b) printf("%d %d\n",a,b)
#define pll(a) printf("%I64d\n",a)
#define oll(a) printf("%lld\n",a)
#define nl printf("\n");
#define sz(a) int((a).size())
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define tr(container, it) for(typeof(container.begin()) it = container.begin(); it != container.end(); it++)
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define f(i,a,b) for(int i=a;i<b;i++)
#define rf(i,a,b) for(int i=a;i>=b;i--)
#define l(a) (int)a.length()
#define maximum(a) (*max_element(all(a)))
#define minimum(a) (*min_element(all(a)))
#define clr(x,a) memset(x,a,sizeof(x))
//#define getchar getchar_unlocked
//#define putchar putchar_unlocked
#define MOD 1000000007

uint inp() {
  uint n;
  int c;
  while( (c = getchar()) < '0') {
    ;
  }
  n = c - '0';
  while( (c = getchar()) >= '0')
    n = n * 10 + (c - '0');
  return n;
}

void pt(uint n) {
  uchar stack[30];
  int top = 0;
  if(n == 0) {
    putchar('0');
  } else {
    while(n > 0) {
      stack[top++] = n % 10 + '0';
      n /= 10;
    }
    while(top > 0) {
      putchar(stack[--top]);
    }
  }
  putchar('\n');
}

int a[1000005],b[1000005],d[1100][1100];
char s1[1000005],s2[1000005];

int nCr(){
    d[0][0]=1;
    f(i,1,1100){
        d[i][0]=1;
        f(j,1,i+1){
            d[i][j]=(d[i-1][j-1]+d[i-1][j])%MOD;
        }
    }
}

int main(){
    int n,i,k,t,c=0,l,y,z,ans=0;
    ll h=1,j,x=0,m;
    si(n);
    nCr();
    f(i,0,n){
        si(a[i]);
        h=(h*d[x+a[i]-1][a[i]-1])%MOD;
        x+=a[i];
    }
    oll(h);

    return 0;
}


/*////////////////////////////////////
       Harsh  Rumalwala
       ---- hr1212 ----
////////////////////////////////////*/

#include <list>
#include <deque>
#include <stack>
#include <bitset>
#include <functional>
#include <utility>
#include <sstream>
#include <iomanip>
#include <ctime>
#include <algorithm>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <stdio.h>
#include <cstdlib>
#include <cctype>
#include <cmath>
#include <numeric>
#include <valarray>
#include <complex>
#include <string.h>
#include <climits>

using namespace std;

const int dr[]={0,-1,0,1,-1,1, 1,-1};
const int dc[]={1,0,-1,0, 1,1,-1,-1};

typedef long long ll;
typedef long long unsigned ull;
typedef long double ld;
typedef unsigned short us;
typedef unsigned int uint;
typedef unsigned char uchar;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef pair<int,pii> piii;
typedef map<int,int> mi;
typedef map<string,int> msi;

#define ss(a) scanf("%s",a)
#define si(a) scanf("%d",&a)
#define sc(a) scanf("%c",&a)
#define sii(a,b) scanf("%d %d",&a,&b)
#define siii(a,b,c) scanf("%d %d %d",&a,&b,&c)
#define sll(a) scanf("%I64d",&a)
#define ill(a) scanf("%lld",&a)
#define pi(a) printf("%d\n",a)
#define op(a) printf("%d ",a)
#define ps(a) printf("%s\n",a)
#define ppi(a,b) printf("%d %d\n",a,b)
#define pll(a) printf("%I64d\n",a)
#define oll(a) printf("%lld\n",a)
#define nl printf("\n");
#define sz(a) int((a).size())
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define tr(container, it) for(typeof(container.begin()) it = container.begin(); it != container.end(); it++)
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define f(i,a,b) for(int i=a;i<b;i++)
#define rf(i,a,b) for(int i=a;i>=b;i--)
#define l(a) (int)a.length()
#define maximum(a) (*max_element(all(a)))
#define minimum(a) (*min_element(all(a)))
#define clr(x,a) memset(x,a,sizeof(x))
//#define getchar getchar_unlocked
//#define putchar putchar_unlocked
#define MOD 1000000007

uint inp() {
  uint n;
  int c;
  while( (c = getchar()) < '0') {
    ;
  }
  n = c - '0';
  while( (c = getchar()) >= '0')
    n = n * 10 + (c - '0');
  return n;
}

void pt(uint n) {
  uchar stack[30];
  int top = 0;
  if(n == 0) {
    putchar('0');
  } else {
    while(n > 0) {
      stack[top++] = n % 10 + '0';
      n /= 10;
    }
    while(top > 0) {
      putchar(stack[--top]);
    }
  }
  putchar('\n');
}

int a[1000005],b[1000005],d[1000][1000];
char s1[1000005],s2[1000005];

int main(){
    int n,i,k,t,c=0,l,y,z,ans=0;
    ll h,j,x=0,m;
    si(n);
    m=n;
    f(i,0,n){
        si(a[i]);
        x+=a[i];
    }
    x-=2;
    if(a[n-1]==1)
        m--;
    if(a[n-2]==1)
        m--;

    h=1;
    for(j=x;j>m;j--){
        h=(h*j);
        if(h>=MOD)
            h%=MOD;
    }

    oll(h);

    return 0;
}


/*////////////////////////////////////
       Harsh  Rumalwala
       ---- hr1212 ----
////////////////////////////////////*/

#include <list>
#include <deque>
#include <stack>
#include <bitset>
#include <functional>
#include <utility>
#include <sstream>
#include <iomanip>
#include <ctime>
#include <algorithm>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <stdio.h>
#include <cstdlib>
#include <cctype>
#include <cmath>
#include <numeric>
#include <valarray>
#include <complex>
#include <string.h>
#include <climits>

using namespace std;

const int dr[]={0,-1,0,1,-1,1, 1,-1};
const int dc[]={1,0,-1,0, 1,1,-1,-1};

typedef long long ll;
typedef long long unsigned ull;
typedef long double ld;
typedef unsigned short us;
typedef unsigned int uint;
typedef unsigned char uchar;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef pair<int,pii> piii;
typedef map<int,int> mi;
typedef map<string,int> msi;

#define ss(a) scanf("%s",a)
#define si(a) scanf("%d",&a)
#define sc(a) scanf("%c",&a)
#define sii(a,b) scanf("%d %d",&a,&b)
#define siii(a,b,c) scanf("%d %d %d",&a,&b,&c)
#define sll(a) scanf("%I64d",&a)
#define ill(a) scanf("%lld",&a)
#define pi(a) printf("%d\n",a)
#define op(a) printf("%d ",a)
#define ps(a) printf("%s\n",a)
#define ppi(a,b) printf("%d %d\n",a,b)
#define pll(a) printf("%I64d\n",a)
#define oll(a) printf("%lld\n",a)
#define nl printf("\n");
#define sz(a) int((a).size())
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define tr(container, it) for(typeof(container.begin()) it = container.begin(); it != container.end(); it++)
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define f(i,a,b) for(int i=a;i<b;i++)
#define rf(i,a,b) for(int i=a;i>=b;i--)
#define l(a) (int)a.length()
#define maximum(a) (*max_element(all(a)))
#define minimum(a) (*min_element(all(a)))
#define clr(x,a) memset(x,a,sizeof(x))
//#define getchar getchar_unlocked
//#define putchar putchar_unlocked
#define MOD 1000000007

uint inp() {
  uint n;
  int c;
  while( (c = getchar()) < '0') {
    ;
  }
  n = c - '0';
  while( (c = getchar()) >= '0')
    n = n * 10 + (c - '0');
  return n;
}

void pt(uint n) {
  uchar stack[30];
  int top = 0;
  if(n == 0) {
    putchar('0');
  } else {
    while(n > 0) {
      stack[top++] = n % 10 + '0';
      n /= 10;
    }
    while(top > 0) {
      putchar(stack[--top]);
    }
  }
  putchar('\n');
}

int a[1000005],b[1000005],d[1000][1000];
char s1[1000005],s2[1000005];

int main(){
    int n,i,k,t,c=0,l,y,z,ans=0;
    ll h,j,x=0,m;
    si(n);
    m=n;
    f(i,0,n){
        si(a[i]);
        x+=a[i];
    }
    if(n==1){
        pi(c);
        return 0;
    }
    x-=2;
    if(a[n-1]==1)
        m--;
    if(a[n-2]==1)
        m--;

    h=1;
    for(j=x;j>m;j--){
        h=(h*j);
        if(h>=MOD)
            h%=MOD;
    }

    oll(h);

    return 0;
}


#include<iostream>
#include<cstdio>
#include<map>
#include<set>
#include<vector>
#include<stack>
#include<queue>
#include<string>
#include<cstring>
#include<sstream>
#include<algorithm>
#include<cmath>
using namespace std;
typedef long long LL;
const LL maxn = 1e6 + 1010;
const LL mod = 1000000007;
LL mul[maxn + 100];
LL exgcd(LL a,LL b,LL &x,LL &y) {
    if (a == 0 && b == 0) return -1;
    if (b == 0) {x = 1,y = 0;return a;}
    LL d = exgcd(b,a%b,y,x);
    y -= a/b*x;
    return d;
}
/*
LL inv(LL a,LL m) {
    if (a == 1) return 1;
    return inv(m%a,m) * (m - m/a)%m;
}
*/
LL inv(LL a,LL n) {
    LL x,y;
    LL d = exgcd(a,n,x,y);
    if (d == 1) return (x%n + n)%n;
    else return -1;
}
LL c(int m,int n) {
    return mul[n]*inv(mul[m],mod)%mod*inv(mul[n-m],mod)%mod;
}
int main()
{
    int n;
    LL ans = 1, sum = 0, k;
    mul[0] = 1;
    for (int i = 1; i <= maxn; i++)
        mul[i] = mul[i-1] * i % mod;
    scanf("%d",&n);
    for (int i = 1;i <= n; i++) {
        scanf("%I64d",&k);
        ans = ans * c(sum,sum+k-1) % mod;
        sum += k;
    }
    printf("%I64d\n",ans);
    return 0;
}


#include<iostream>
#include<cstdio>
#include<map>
#include<set>
#include<vector>
#include<stack>
#include<queue>
#include<string>
#include<cstring>
#include<sstream>
#include<algorithm>
#include<cmath>
using namespace std;
typedef long long LL;
const LL maxn = 1e6 + 1010;
const LL mod = 1000000007;
LL mul[maxn + 100];
LL c(int m,int n) {
    return mul[n]/mul[m]/mul[n-m];
}
int main()
{
    int n;
    LL ans = 1, sum = 0, k;
    mul[0] = 1;
    for (int i = 1; i <= maxn; i++)
        mul[i] = mul[i-1] * i % mod;
    scanf("%d",&n);
    for (int i = 1;i <= n; i++) {
        scanf("%I64d",&k);
        ans = ans * c(sum,sum+k-1) % mod;
        sum += k;
    }
    printf("%I64d\n",ans);
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
int dp[1002][1002];
long long m = 1000000007;
long long binomialCoeff(int n, int k)
{
    int i, j;
    for (i = 0; i <= n; i++)
    {
        for (j = 0; j <= min(i, k); j++)
        {
            if (j == 0 || j == i)
                dp[i][j] = 1;
            else
                dp[i][j] = ((dp[i-1][j-1])%m + (dp[i-1][j])%m)%m;
        }
    }

    return dp[n][k];
}

long long dp1[1001];

int main()
{
    binomialCoeff(1001,1001);
    int a, b;
    int n;
    cin >> n;
    int ara[1001];
    for(int i = 1; i <= n; i++)cin >> ara[i];
    a = ara[1] - 1, b = 0;
    dp1[1] = 1;
    for(int i = 2; i <= n; i++)
    {
        a += (ara[i]);
        b = ara[i] - 1;
        dp1[i] = (dp1[i-1] * dp[a][b] % m);

    }
    cout << dp1[n] << endl;
    return 0;

}


#include <bits/stdc++.h>
using namespace std;
int dp[1002][1002];
long long m = 1000000007;
long long binomialCoeff(int n, int k)
{
    int i, j;

    // Caculate value of Binomial Coefficient in bottom up manner
    for (i = 0; i <= n; i++)
    {
        for (j = 0; j <= min(i, k); j++)
        {
            // Base Cases
            if (j == 0 || j == i)
                dp[i][j] = 1;

            // Calculate value using previosly stored values
            else
                dp[i][j] = ((dp[i-1][j-1])%m + (dp[i-1][j])%m)%m;
        }
    }

    return dp[n][k];
}

long long dp1[1001];

int main()
{
    binomialCoeff(1001,1001);
    int a, b;
//    while(cin >> a)
//    {
//        cin >> b;
//        cout << dp[a][b]<<endl;
//    }
    int n;
    cin >> n;
    int ara[1001];
    for(int i = 1; i <= n; i++)cin >> ara[i];
    a = ara[1] - 1, b = 0;
    dp1[1] = 1;
    for(int i = 2; i <= n; i++)
    {
        a += (ara[i]);
        b = ara[i] - 1;
        //cout << a << " "<<b<<endl;
        dp1[i] = (dp1[i-1] * dp[a][b] % m);

    }
    cout << dp1[n] << endl;
    return 0;

}


#include <bits/stdc++.h>
using namespace std;
int dp[1001][1001];
long long m = 1000000007;
long long binomialCoeff(int n, int k)
{
    int i, j;

    // Caculate value of Binomial Coefficient in bottom up manner
    for (i = 0; i <= n; i++)
    {
        for (j = 0; j <= min(i, k); j++)
        {
            // Base Cases
            if (j == 0 || j == i)
                dp[i][j] = 1;

            // Calculate value using previosly stored values
            else
                dp[i][j] = ((dp[i-1][j-1])%m + (dp[i-1][j])%m)%m;
        }
    }

    return dp[n][k];
}

long long dp1[1001];

int main()
{
    binomialCoeff(1001,1001);
    int a, b;
//    while(cin >> a)
//    {
//        cin >> b;
//        cout << dp[a][b]<<endl;
//    }
    int n;
    cin >> n;
    int ara[1001];
    for(int i = 1; i <= n; i++)cin >> ara[i];
    a = ara[1] - 1, b = 0;
    dp1[1] = 1;
    for(int i = 2; i <= n; i++)
    {
        a += (ara[i]);
        b = ara[i] - 1;
        //cout << a << " "<<b<<endl;
        dp1[i] = (dp1[i-1] * dp[a][b] % m);

    }
    cout << dp1[n] << endl;
    return 0;

}


#include<bits/stdc++.h>
using namespace std;
long long int x,y,z,mx,n,m,s;
int a[1005];
int b[1005];
long long int fc[1000];
void fx()
{
    int i;
    for(i=0;i<n;i++)
    {
        if(b[i]>0 && mx%fc[b[i]]==0 && mx>b[i])
        {
            mx/=b[i];
            b[i]=0;
        }
    }
}
int main()
{
    ios_base::sync_with_stdio(false);
    int i,j,k,l;
    cin>>n;
    for(i=0;i<n;i++)
        {
            cin>>a[i];
            b[i]=a[i];
            if(i>=n-2)
                b[i]--;
        }
    sort(a,a+n);
    sort(b,b+n);
    mx=1;
    for(i=0;i<n;i++)
    {
        s+=b[i];
    }
    memset(fc,0,sizeof(0));
    mx=1;
    fc[0]=1;
    for(i=1;i<50;i++)
    {
        mx*=i;
        fc[i]=mx;
    }
    mx=1;
    for(i=b[n-1];i<=s;i++)
    {
        mx*=i;
        fx();
    }
    cout<<mx<<endl;

    return 0;
}


#include<bits/stdc++.h>
using namespace std;
long long int x,y,z,mx,n,m,s;
int a[1005];
int b[1005];
long long int fc[1000];
void fx()
{
    int i;
    y=0;
    for(i=0;i<n-1;i++)
    {
        y=b[i];
        if(b[i]>1 && mx>b[i])
        {
            while(y>1)
            {
                mx/=y;
                y--;
            }
            b[i]=0;
        }
    }
}
int main()
{
    ios_base::sync_with_stdio(false);
    int i,j,k,l;
    cin>>n;
    for(i=0;i<n;i++)
        {
            cin>>a[i];
            b[i]=a[i];
            if(i>=n-2)
                b[i]--;
        }
   // sort(a,a+n);
    sort(b,b+n);
    mx=1;
    for(i=0;i<n;i++)
    {
        s+=b[i];
    }
    mx=1;
    for(i=b[n-1]+1;i<=s;i++)
    {
        mx*=i;
        fx();
    }
   // fx();
    cout<<mx<<endl;

    return 0;
}


#include<bits/stdc++.h>
using namespace std;
long long int x,y,mx,n,m,s;
int a[1005];
int b[1005],z=0;
int fc[1000000];
void fx()
{
    int i;
    y=0;
    for(i=0;i<n-1;i++)
    {
        y=b[i];
        if(b[i]>1 && mx>b[i])
        {
            while(y>1)
            {
                if(mx%y==0)
                {
                    mx/=y;
                }
                else
                {
                    fc[z++]=y;
                }
                y--;
            }
            b[i]=0;
        }
    }
    for(i=0;i<z;i++)
    {
        if(fc[i]>0 && mx%fc[i]==0 && mx>fc[i])
            mx/=fc[i];
    }
}
int main()
{
    ios_base::sync_with_stdio(false);
    int i,j,k,l;
    cin>>n;
    for(i=0;i<n;i++)
        {
            cin>>a[i];
            b[i]=a[i];
            if(i>=n-2)
                b[i]--;
        }
   // sort(a,a+n);
    sort(b,b+n);
    mx=1;
    for(i=0;i<n;i++)
    {
        s+=b[i];
    }
    mx=1;
    for(i=b[n-1]+1;i<=s;i++)
    {
        mx*=i;
        fx();
    }
   // fx();
    cout<<mx<<endl;

    return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long L;

#define mod 1000000007

int c[1001][1001];

signed main() {
#ifndef ONLINE_JUDGE
    //freopen("int.txt","r",stdin);
    //freopen("out.txt","w",stdout);
#endif
    ios_base::sync_with_stdio(false);cin.tie(false);

    for(int i=0; i<1001; i++) {
        c[i][0] = 1;
        c[i][i] = 1;
    }

    for(int i=1; i<1001; i++) {
        for(int j=1; j<i; j++) {
            c[i][j] = (c[i-1][j] + c[i-1][j-1])%mod;
        }
    }

    int k;
    cin>>k;

    vector<int> a(k);

    for(int i=0; i<k; i++) {
        cin>>a[i];
    }

    L ans=1;
    L cf = a[0];

    for(int i=1; i<k; i++) {
        ans = (ans * c[cf + a[i] - 1][cf])%mod;
        ans = (ans + mod)%mod;

        cf+=a[i];
    }

    cout<<ans;

    return 0;
}


#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <iostream>
#include <string>
#include <queue>
using namespace std;
#define gmax(a,b) a>b?a:b
#define gmin(a,b) a<b?a:b
typedef long long LL;
const LL MOD = 1e9+7;
const int MAXN = 1000+10;
int lv[MAXN];
LL dp[1000+5];
LL jia[1000+10][1000+10];
int n;
//int _pow(int a,int b)
//{
//    if(b == 0)
//        return 1;
//    int tt = a;
//    int ans = 0;
//    while(b){
//        if(b & 1)
//            ans = (ans + tt) % MOD;
//        tt = (tt*tt) % MOD;
//        b = b>>1;
//    }
//    return ans;
//}
void init()
{
    for(int i=0; i<=1000+5; i++){
        int sum = 0;
        for(int j=0; j<=1000+5; j++){
            if(i==0)
                jia[i][j] = 1;
            else{
               if(j <= 1)
                    sum = jia[i-1][j];
               else
                    sum = (sum + jia[i-1][j]) % MOD;
               jia[i][j] = sum;
            }
        }
    }
}
int main()
{
    init();
//    for(int i=0; i<4; i++){
//        for(int j=0; j<4; j++)
//            printf("%d ",jia[i][j]);
//        printf("\n");
//    }
    while(scanf("%d",&n) != EOF){
        for(int i=1; i<=n; i++)
            scanf("%d",&lv[i]);
        memset(dp, 0, sizeof(dp));
        LL pre,sum;
        pre = sum = 0;
        for(int i=1; i<=n; i++){
            if(i == 1){
                pre = sum = lv[i];
                dp[1] = 1;
            }
            else{
//                int tans = _pow(pre+1, lv[i]-1);
//                dp[i] = (tans * dp[i-1]) % MOD;
//                if(jia[pre+1][lv[i]-1] == 0)
//                    dp[i] = dp[i-1];
//                else
                int f1 = pre+1;
                int f2 = lv[i]-1;
//                printf("f1 = %d,f2 = %d\n",pre+1,lv[i]-1);
//                printf("jia = %d\n",jia[pre+1][lv[i]-1]);
                dp[i] = (jia[f2][f1] * dp[i-1]) % MOD;
                sum = sum + lv[i];
                pre = sum;
            }

//            printf("pre = %d,sum = %d,now dp max = %d\n",pre,sum,dp[i]);
        }
        printf("%I64d\n",dp[n]);
    }
    return 0;
}


#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <iostream>
#include <string>
#include <queue>
using namespace std;
#define gmax(a,b) a>b?a:b
#define gmin(a,b) a<b?a:b
typedef long long LL;
const LL MOD = 1e9+7;
const int MAXN = 100+5;
int lv[MAXN];
LL dp[1000+5];
LL jia[1000+10][1000+10];
int n;
//int _pow(int a,int b)
//{
//    if(b == 0)
//        return 1;
//    int tt = a;
//    int ans = 0;
//    while(b){
//        if(b & 1)
//            ans = (ans + tt) % MOD;
//        tt = (tt*tt) % MOD;
//        b = b>>1;
//    }
//    return ans;
//}
void init()
{
    for(int i=0; i<=1000+5; i++){
        int sum = 0;
        for(int j=0; j<=1000+5; j++){
            if(i==0)
                jia[i][j] = 1;
            else{
               if(j <= 1)
                    sum = jia[i-1][j];
               else
                    sum = (sum + jia[i-1][j]) % MOD;
               jia[i][j] = sum;
            }
        }
    }
}
int main()
{
    init();
//    for(int i=0; i<4; i++){
//        for(int j=0; j<4; j++)
//            printf("%d ",jia[i][j]);
//        printf("\n");
//    }
    while(scanf("%d",&n) != EOF){
        for(int i=1; i<=n; i++)
            scanf("%d",&lv[i]);
        memset(dp, 0, sizeof(dp));
        LL pre,sum;
        pre = sum = 0;
        for(int i=1; i<=n; i++){
            if(i == 1){
                pre = sum = lv[i];
                dp[1] = 1;
            }
            else{
//                int tans = _pow(pre+1, lv[i]-1);
//                dp[i] = (tans * dp[i-1]) % MOD;
//                if(jia[pre+1][lv[i]-1] == 0)
//                    dp[i] = dp[i-1];
//                else
                int f1 = pre+1;
                int f2 = lv[i]-1;
//                printf("f1 = %d,f2 = %d\n",pre+1,lv[i]-1);
//                printf("jia = %d\n",jia[pre+1][lv[i]-1]);
                dp[i] = (jia[f2][f1] * dp[i-1]) % MOD;
                sum = sum + lv[i];
                pre = sum;
            }

//            printf("pre = %d,sum = %d,now dp max = %d\n",pre,sum,dp[i]);
        }
        printf("%I64d\n",dp[n]);
    }
    return 0;
}


#include "bits/stdc++.h"
using namespace std;
int main ()
{
    long long fact,b=0,c=0,p=0;
    int k;
    int a [1005];
    cin >>k;
    for (int i = 0; i < k; i++)
    { cin>> a[i];
    c+=a[i];

    }
     b=b+c-k+1;
  //  cout <<b;
    for (int j = 0; j <= b; j++)
    {
        if (j == 0)
        fact = 1;
        else
        fact = (fact * j)%1000000007;}
    p=fact/(k-1);
    cout<<p;

return 0;
}


#include "bits/stdc++.h"
using namespace std;
int main ()
{
    long long fact,b=0,c=0,p=0;
    int k;
    int a [1005];
    cin >>k;
    if (k==1)
        cout<<0;
    else
    {
    for (int i = 0; i < k; i++)
    { cin>> a[i];
    c+=a[i];

    }
     b=b+c-k+1;
  //  cout <<b;
    for (int j = 0; j <= b; j++)
    {
        if (j == 0)
        fact = 1;
        else
        fact = (fact * j)%1000000007;}
    p=fact/(k-1);
    cout<<p;
    }
return 0;
}


# include <iostream>
# include <fstream>
# include <sstream>
# include <algorithm>
# include <cstdio>
# include <cmath>
# include <numeric>
# include <cstdlib>
# include <cstring>
# include <vector>
# include <list>
# include <set>
# include <map>
# include <stack>
# include <queue>
# include <cctype>
# include <climits>
# include <complex>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef long long int lli;
typedef pair<long long int,long long int> pll;
typedef vector<int> vi;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rof(i,a,b) for(int i=a;i>b;i--)
#define pb push_back
#define mp make_pair
#define inf 1000000000
#define mod 1000000007
#define mst(a,b) memset(a,b,sizeof(a))
#define pi (double)(3.141592653589793)

lli k;
lli a[1010];
lli sum[1010];
lli dp[2100][2100];

lli nCr()
{
    dp[0][0] = 1;
    rep(i,0,2010)
    dp[i][0]=1;
    rep(i,1,2010)
    dp[0][i]=0;
    rep(i,1,2010)
    rep(j,1,2010)
     {
         dp[i][j] = dp[i-1][j] + dp[i-1][j-1];
         while(dp[i][j]>=mod)
            dp[i][j]-=mod;
     }
}

int main()
{
    nCr();
    //cout<<dp[1000][2121]<<" ";
lli ans=1;
cin>>k;
sum[0]=0;
rep(i,1,k+1)
{
    cin>>a[i];
sum[i]=sum[i-1]+a[i];
}

rep(i,2,k+1)
{
    ans=(ans*dp[sum[i-1]+a[i]-1][sum[i-1]]);
    while(ans>=mod)
        ans-=mod;
}
cout<<ans;

return 0;
}


# include <iostream>
# include <fstream>
# include <sstream>
# include <algorithm>
# include <cstdio>
# include <cmath>
# include <numeric>
# include <cstdlib>
# include <cstring>
# include <vector>
# include <list>
# include <set>
# include <map>
# include <stack>
# include <queue>
# include <cctype>
# include <climits>
# include <complex>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef long long int lli;
typedef pair<long long int,long long int> pll;
typedef vector<int> vi;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rof(i,a,b) for(int i=a;i>b;i--)
#define pb push_back
#define mp make_pair
#define inf 1000000000
#define mod 1000000007
#define mst(a,b) memset(a,b,sizeof(a))
#define pi (double)(3.141592653589793)

lli k;
lli a[1010];
lli sum[1010];
lli dp[1100][1100];

void nCr()
{
    dp[0][0] = 1;
    rep(i,0,1010)
    dp[i][0]=1;
    rep(i,1,1010)
    dp[0][i]=0;
    rep(i,1,1010)
    rep(j,1,1010)
     {
         dp[i][j] = (dp[i-1][j] + dp[i-1][j-1])%mod;
         //while(dp[i][j]>=mod)
           // dp[i][j]-=mod;
     }
}

int main()
{
    nCr();
    //cout<<dp[1000][2121]<<" ";
lli ans=1;
scanf("%lld",&k);
sum[0]=0;
rep(i,1,k+1)
{
    scanf("%lld",&a[i]);
sum[i]=sum[i-1]+a[i];
}

rep(i,2,k+1)
{
    ans=(ans*dp[sum[i-1]+a[i]-1][sum[i-1]])%mod;
   //while(ans>=mod)
        //ans-=mod;
}
printf("%lld",ans%mod);

return 0;
}


# include <iostream>
# include <fstream>
# include <sstream>
# include <algorithm>
# include <cstdio>
# include <cmath>
# include <numeric>
# include <cstdlib>
# include <cstring>
# include <vector>
# include <list>
# include <set>
# include <map>
# include <stack>
# include <queue>
# include <cctype>
# include <climits>
# include <complex>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef long long int lli;
typedef pair<long long int,long long int> pll;
typedef vector<int> vi;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rof(i,a,b) for(int i=a;i>b;i--)
#define pb push_back
#define mp make_pair
#define inf 1000000000
#define mod 1000000007
#define mst(a,b) memset(a,b,sizeof(a))
#define pi (double)(3.141592653589793)

lli k;
lli a[1010];
lli sum[1010];
lli dp[1100][1100];

void nCr()
{
    dp[0][0] = 1;
    rep(i,0,1010)
    dp[i][0]=1;
    rep(i,1,1010)
    dp[0][i]=0;
    rep(i,1,1010)
    rep(j,1,1010)
     {
         dp[i][j] = dp[i-1][j] + dp[i-1][j-1];
         while(dp[i][j]>=mod)
            dp[i][j]-=mod;
     }
}

int main()
{
    nCr();
    //cout<<dp[1000][2121]<<" ";
lli ans=1;
scanf("%lld",&k);
sum[0]=0;
rep(i,1,k+1)
{
    scanf("%lld",&a[i]);
sum[i]=sum[i-1]+a[i];
}

rep(i,2,k+1)
{
    ans=(ans*dp[sum[i-1]+a[i]-1][sum[i-1]]);
   while(ans>=mod)
        ans-=mod;
}
printf("%lld",ans);

return 0;
}


#include <bits/stdc++.h>
#define MOD 1000000007
#define N 1024

using namespace std;
int n;
long long int tab[N];
int comb[N][N]={0};

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cin>>n;
	for(int i=0;i<N;++i)
		comb[i][0]=1;
	for(int i=1;i<N;++i)
	{
		for(int j=1;j<=i;++j)
		{
			comb[i][j]=(comb[i-1][j-1]+comb[i-1][j])%MOD;
		}
	}
	for(int i=0;i<n;++i)
	{
		cin>>tab[i];
	}
	long long int sum=0;
	long long int res=1;
	for(int i=0;i<n;++i)
	{
		sum+=tab[i];
		res=(res*comb[sum-1][tab[i]-1])%MOD;
	}
	cout<<res<<endl;
	return 0;
}


#include <bits/stdc++.h>
#define MOD 1000000007
#define N 1024

using namespace std;
int n;
long long int tab[N];

long long int Comb(int n,int p)
{
	long long int product=1;
	for(int i=1;i<=p;++i)
	{
		product=(product*(n-i+1))/i;
	}
	product%=MOD;
	return product;
}

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cin>>n;
	for(int i=0;i<n;++i)
	{
		cin>>tab[i];
	}
	long long int sum=0;
	long long int res=1;
	for(int i=0;i<n;++i)
	{
		sum+=tab[i];
		long long int k=Comb(sum-1,tab[i]-1);
		res=(res*k)%MOD;
	}
	cout<<res<<endl;
	return 0;
}


#include <bits/stdc++.h>
#define MOD 1000000007
#define N 1024

using namespace std;
int n;
long long int tab[N];

long long int Comb(int n,int p)
{
	long long int product=1;
	for(int i=1;i<=p;++i)
	{
		product=(product*(n-p+i))/i;
	}
	product%=MOD;
	return product;
}

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cin>>n;
	for(int i=0;i<n;++i)
	{
		cin>>tab[i];
	}
	long long int sum=0;
	long long int res=1;
	for(int i=0;i<n;++i)
	{
		sum+=tab[i];
		long long int k=Comb(sum-1,tab[i]-1);
		res=(res*k)%MOD;
	}
	cout<<res<<endl;
	return 0;
}


#include <bits/stdc++.h>
#define MOD 1000000007
#define N 1024

using namespace std;
int n;
long long int tab[N];

long long int Comb(int n,int p)
{
	long long int product=1;
	for(int i=1;i<=p;++i)
	{
		product=(product*(n-p+i))/i;
		product%=MOD;
	}
	return product;
}

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cin>>n;
	for(int i=0;i<n;++i)
	{
		cin>>tab[i];
	}
	long long int sum=0;
	long long int res=1;
	for(int i=0;i<n;++i)
	{
		sum+=tab[i];
		long long int k=Comb(sum-1,tab[i]-1);
		res=(res*k)%MOD;
	}
	cout<<res<<endl;
	return 0;
}


/**********************************************************************************************************************************

Author  : Vivek Nynaru
Handle  : kevin11

 **********************************************************************************************************************************/

#include<bits/stdc++.h>
using namespace std;
#define SpeedUp std::ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

/* Typedef's for most frequently used DataTypes */

typedef long long int ll;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef set<int> si;
typedef map<int,int> mii;
typedef map<string,int> msi;
typedef priority_queue < ll , vector < ll > , greater < ll > > minheap;
typedef priority_queue < ll , vector < ll > , less < ll > > maxheap;

/* Most frequently used Constants */

#define INF 1000000000000000000
#define PI M_PI
#define E M_E
#define MOD 1000000007

/* Most frequently used Functions */

#define pb push_back
#define pp pop_back
#define mp make_pair
#define F first
#define S second

/* For variables */

#define LET(x,a) __typeof(a) x(a)

/* Iterations */

#define rep(i, a, b) for (int i = int(a);i <= int(b); i++)
#define rev(i, a, b) for (int i = int(b);i >= int(a); i--)
#define repi(i, a, b) for (int i = int(a);i < int(b); i++)
#define revi(i, a, b) for (int i = int(b);i > int(a); i--)
#define tr(v,it) for( LET(it,v.begin()) ; it != v.end() ; it++)
#define rtr(v,it) for( LET(it,v.rbegin()) ; it != v.rend() ; it++)
#define TC() int tc;cin >> tc; while(tc--)

/* Initialisation */

#define init(a,b) memset(a,b,sizeof(a))

/* Debugging */

#define TRACE
#ifdef TRACE
#define trace1(x)                cerr << #x << ": " << x << endl;
#define trace2(x, y)             cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
#define trace3(x, y, z)          cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl;
#define trace4(a, b, c, d)       cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << endl;
#define trace5(a, b, c, d, e)    cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << endl;
#define trace6(a, b, c, d, e, f) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << " | " << #f << ": " << f << endl;
#else
#define trace1(x)
#define trace2(x, y)
#define trace3(x, y, z)
#define trace4(a, b, c, d)
#define trace5(a, b, c, d, e)
#define trace6(a, b, c, d, e, f)
#endif

/* Finding */

#define ALL(a) a.begin(),a.end()
#define LB(a,x) (lower_bound(ALL(a),x)-a.begin())
#define UB(a,x) (upper_bound(ALL(a),x)-a.begin())

/* Exponentiation */

inline ll Pow(ll a, ll b, ll mod){ll res=1;while(b){if(b&1)res=(res*a)%mod;a=(a*a)%mod;b>>=1;}return res;}

/**********************************************************************************************************************************

  Main Code

 **********************************************************************************************************************************/
ll fact[1000001];
ll ex(ll a, ll b, ll m)
{
	if(b==0)
		return 1;
	if(b&1==1)
		return (a*ex((a*a)%m,b>>1,m))%m;
	else
		return ex((a*a)%m,b>>1,m)%m;
}
ll inv(ll x)
{
	return ex(x, MOD-2, MOD);
}
ll comb(ll a, ll b)
{
	return ((fact[a]*inv(fact[b])%MOD)*inv(fact[a-b]))%MOD;
}
ll val[1001],dp[1001];
int main()
{
	ll k;
	SpeedUp;
	fact[0]=1;
	rep(i,1,1000000)
		fact[i]=(fact[i-1]*i)%MOD;
	cin >> k;
	rep(i,1,k)
		cin >> val[i];
	dp[1]=1;
	ll tot=0;
	rep(i,2,k)
	{
		tot+=val[i-1];
		ll b=val[i];
		dp[i]=((dp[i-1]*(comb(tot+1,b-1)))%MOD);
	}
	cout << (dp[k]*k)%MOD << "\n";
	return 0;
}


/**********************************************************************************************************************************

Author  : Vivek Nynaru
Handle  : kevin11

 **********************************************************************************************************************************/

#include<bits/stdc++.h>
using namespace std;
#define SpeedUp std::ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

/* Typedef's for most frequently used DataTypes */

typedef long long int ll;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef set<int> si;
typedef map<int,int> mii;
typedef map<string,int> msi;
typedef priority_queue < ll , vector < ll > , greater < ll > > minheap;
typedef priority_queue < ll , vector < ll > , less < ll > > maxheap;

/* Most frequently used Constants */

#define INF 1000000000000000000
#define PI M_PI
#define E M_E
#define MOD 1000000007

/* Most frequently used Functions */

#define pb push_back
#define pp pop_back
#define mp make_pair
#define F first
#define S second

/* For variables */

#define LET(x,a) __typeof(a) x(a)

/* Iterations */

#define rep(i, a, b) for (int i = int(a);i <= int(b); i++)
#define rev(i, a, b) for (int i = int(b);i >= int(a); i--)
#define repi(i, a, b) for (int i = int(a);i < int(b); i++)
#define revi(i, a, b) for (int i = int(b);i > int(a); i--)
#define tr(v,it) for( LET(it,v.begin()) ; it != v.end() ; it++)
#define rtr(v,it) for( LET(it,v.rbegin()) ; it != v.rend() ; it++)
#define TC() int tc;cin >> tc; while(tc--)

/* Initialisation */

#define init(a,b) memset(a,b,sizeof(a))

/* Debugging */

#define TRACE
#ifdef TRACE
#define trace1(x)                cerr << #x << ": " << x << endl;
#define trace2(x, y)             cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
#define trace3(x, y, z)          cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl;
#define trace4(a, b, c, d)       cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << endl;
#define trace5(a, b, c, d, e)    cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << endl;
#define trace6(a, b, c, d, e, f) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << " | " << #f << ": " << f << endl;
#else
#define trace1(x)
#define trace2(x, y)
#define trace3(x, y, z)
#define trace4(a, b, c, d)
#define trace5(a, b, c, d, e)
#define trace6(a, b, c, d, e, f)
#endif

/* Finding */

#define ALL(a) a.begin(),a.end()
#define LB(a,x) (lower_bound(ALL(a),x)-a.begin())
#define UB(a,x) (upper_bound(ALL(a),x)-a.begin())

/* Exponentiation */

inline ll Pow(ll a, ll b, ll mod){ll res=1;while(b){if(b&1)res=(res*a)%mod;a=(a*a)%mod;b>>=1;}return res;}

/**********************************************************************************************************************************

  Main Code

 **********************************************************************************************************************************/
ll fact[1000001];
ll ex(ll a, ll b, ll m)
{
	if(b==0)
		return 1;
	if(b&1==1)
		return (a*ex((a*a)%m,b>>1,m))%m;
	else
		return ex((a*a)%m,b>>1,m)%m;
}
ll inv(ll x)
{
	return ex(x, MOD-2, MOD);
}
ll comb(ll a, ll b)
{
	return ((fact[a]*inv(fact[b])%MOD)*inv(fact[a-b]))%MOD;
}
ll val[1001],dp[1001];
int main()
{
	ll k;
	SpeedUp;
	fact[0]=1;
	rep(i,1,1000000)
		fact[i]=(fact[i-1]*i)%MOD;
	cin >> k;
	rep(i,1,k)
		cin >> val[i];
	dp[1]=1;
	ll tot=0;
	rep(i,2,k)
	{
		tot+=val[i-1];
		ll b=val[i];
		dp[i]=((dp[i-1]*(comb(tot+1,b-1)))%MOD);
	}
	cout << (dp[k]*val[k])%MOD << "\n";
	return 0;
}


/**********************************************************************************************************************************

Author  : Vivek Nynaru
Handle  : kevin11

 **********************************************************************************************************************************/

#include<bits/stdc++.h>
using namespace std;
#define SpeedUp std::ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

/* Typedef's for most frequently used DataTypes */

typedef long long int ll;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef set<int> si;
typedef map<int,int> mii;
typedef map<string,int> msi;
typedef priority_queue < ll , vector < ll > , greater < ll > > minheap;
typedef priority_queue < ll , vector < ll > , less < ll > > maxheap;

/* Most frequently used Constants */

#define INF 1000000000000000000
#define PI M_PI
#define E M_E
#define MOD 1000000007

/* Most frequently used Functions */

#define pb push_back
#define pp pop_back
#define mp make_pair
#define F first
#define S second

/* For variables */

#define LET(x,a) __typeof(a) x(a)

/* Iterations */

#define rep(i, a, b) for (int i = int(a);i <= int(b); i++)
#define rev(i, a, b) for (int i = int(b);i >= int(a); i--)
#define repi(i, a, b) for (int i = int(a);i < int(b); i++)
#define revi(i, a, b) for (int i = int(b);i > int(a); i--)
#define tr(v,it) for( LET(it,v.begin()) ; it != v.end() ; it++)
#define rtr(v,it) for( LET(it,v.rbegin()) ; it != v.rend() ; it++)
#define TC() int tc;cin >> tc; while(tc--)

/* Initialisation */

#define init(a,b) memset(a,b,sizeof(a))

/* Debugging */

#define TRACE
#ifdef TRACE
#define trace1(x)                cerr << #x << ": " << x << endl;
#define trace2(x, y)             cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
#define trace3(x, y, z)          cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl;
#define trace4(a, b, c, d)       cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << endl;
#define trace5(a, b, c, d, e)    cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << endl;
#define trace6(a, b, c, d, e, f) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << " | " << #f << ": " << f << endl;
#else
#define trace1(x)
#define trace2(x, y)
#define trace3(x, y, z)
#define trace4(a, b, c, d)
#define trace5(a, b, c, d, e)
#define trace6(a, b, c, d, e, f)
#endif

/* Finding */

#define ALL(a) a.begin(),a.end()
#define LB(a,x) (lower_bound(ALL(a),x)-a.begin())
#define UB(a,x) (upper_bound(ALL(a),x)-a.begin())

/* Exponentiation */

inline ll ex(ll a, ll b, ll mod){ll res=1;while(b){if(b&1)res=(res*a)%mod;a=(a*a)%mod;b>>=1;}return res;}

/**********************************************************************************************************************************

  Main Code

 **********************************************************************************************************************************/
ll fact[1000001];
/*ll ex(ll a, ll b, ll m)
{
	if(b==0)
		return 1;
	if(b&1==1)
		return (a*ex((a*a)%m,b>>1,m))%m;
	else
		return ex((a*a)%m,b>>1,m)%m;
}*/
ll inv(ll x)
{
	return ex(x, MOD-2, MOD);
}
ll comb(ll a, ll b)
{
	return ((fact[a]*inv(fact[b])%MOD)*inv(fact[a-b]))%MOD;
}
ll val[1001],dp[1001];
int main()
{
	ll k;
	SpeedUp;
	fact[0]=1;
	rep(i,1,1000000)
		fact[i]=(fact[i-1]*i)%MOD;
	cin >> k;
	rep(i,1,k)
		cin >> val[i];
	dp[1]=1;
	ll tot=0;
	rep(i,2,k)
	{
		tot+=val[i-1];
		ll b=val[i];
		dp[i]=((dp[i-1]*(comb(b-1+tot,tot)))%MOD);
	}
	cout << dp[k] << "\n";
	return 0;
}


/**********************************************************************************************************************************

Author  : Vivek Nynaru
Handle  : kevin11

 **********************************************************************************************************************************/

#include<bits/stdc++.h>
using namespace std;
#define SpeedUp std::ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

/* Typedef's for most frequently used DataTypes */

typedef long long int ll;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef set<int> si;
typedef map<int,int> mii;
typedef map<string,int> msi;
typedef priority_queue < ll , vector < ll > , greater < ll > > minheap;
typedef priority_queue < ll , vector < ll > , less < ll > > maxheap;

/* Most frequently used Constants */

#define INF 1000000000000000000
#define PI M_PI
#define E M_E
#define MOD 1000000007

/* Most frequently used Functions */

#define pb push_back
#define pp pop_back
#define mp make_pair
#define F first
#define S second

/* For variables */

#define LET(x,a) __typeof(a) x(a)

/* Iterations */

#define rep(i, a, b) for (int i = int(a);i <= int(b); i++)
#define rev(i, a, b) for (int i = int(b);i >= int(a); i--)
#define repi(i, a, b) for (int i = int(a);i < int(b); i++)
#define revi(i, a, b) for (int i = int(b);i > int(a); i--)
#define tr(v,it) for( LET(it,v.begin()) ; it != v.end() ; it++)
#define rtr(v,it) for( LET(it,v.rbegin()) ; it != v.rend() ; it++)
#define TC() int tc;cin >> tc; while(tc--)

/* Initialisation */

#define init(a,b) memset(a,b,sizeof(a))

/* Debugging */

#define TRACE
#ifdef TRACE
#define trace1(x)                cerr << #x << ": " << x << endl;
#define trace2(x, y)             cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
#define trace3(x, y, z)          cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl;
#define trace4(a, b, c, d)       cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << endl;
#define trace5(a, b, c, d, e)    cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << endl;
#define trace6(a, b, c, d, e, f) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << " | " << #f << ": " << f << endl;
#else
#define trace1(x)
#define trace2(x, y)
#define trace3(x, y, z)
#define trace4(a, b, c, d)
#define trace5(a, b, c, d, e)
#define trace6(a, b, c, d, e, f)
#endif

/* Finding */

#define ALL(a) a.begin(),a.end()
#define LB(a,x) (lower_bound(ALL(a),x)-a.begin())
#define UB(a,x) (upper_bound(ALL(a),x)-a.begin())

/* Exponentiation */

inline ll Pow(ll a, ll b, ll mod){ll res=1;while(b){if(b&1)res=(res*a)%mod;a=(a*a)%mod;b>>=1;}return res;}

/**********************************************************************************************************************************

  Main Code

 **********************************************************************************************************************************/
ll fact[1000001];
ll ex(ll a, ll b, ll m)
{
	if(b==0)
		return 1;
	if(b&1==1)
		return (a*ex((a*a)%m,b>>1,m))%m;
	else
		return ex((a*a)%m,b>>1,m)%m;
}
ll inv(ll x)
{
	return ex(x, MOD-2, MOD);
}
ll comb(ll a, ll b)
{
	return ((fact[a]*inv(fact[b])%MOD)*inv(fact[a-b]))%MOD;
}
ll val[1001],dp[1001];
int main()
{
	ll k;
	SpeedUp;
	fact[0]=1;
	rep(i,1,1000000)
		fact[i]=(fact[i-1]*i)%MOD;
	cin >> k;
	rep(i,1,k)
		cin >> val[i];
	dp[1]=1;
	ll tot=0;
	rep(i,2,k)
	{
		tot+=val[i-1];
		ll b=val[i];
		dp[i]=((dp[i-1]*(comb(b-1+tot,tot)))%MOD);
	}
	cout << dp[k] << "\n";
	return 0;
}


/**********************************************************************************************************************************

						     Author  : Vivek Nynaru
   						     Handle  : kevin11

**********************************************************************************************************************************/

#include<bits/stdc++.h>
using namespace std;
#define SpeedUp std::ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

/* Typedef's for most frequently used DataTypes */

typedef long long int ll;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef set<int> si;
typedef map<int,int> mii;
typedef map<string,int> msi;
typedef priority_queue < ll , vector < ll > , greater < ll > > minheap;
typedef priority_queue < ll , vector < ll > , less < ll > > maxheap;

/* Most frequently used Constants */

#define INF 1000000000000000000
#define PI M_PI
#define E M_E
#define MOD 1000000007

/* Most frequently used Functions */

#define pb push_back
#define pp pop_back
#define mp make_pair
#define F first
#define S second

/* For variables */

#define LET(x,a) __typeof(a) x(a)

/* Iterations */

#define rep(i, a, b) for (int i = int(a);i <= int(b); i++)
#define rev(i, a, b) for (int i = int(b);i >= int(a); i--)
#define repi(i, a, b) for (int i = int(a);i < int(b); i++)
#define revi(i, a, b) for (int i = int(b);i > int(a); i--)
#define tr(v,it) for( LET(it,v.begin()) ; it != v.end() ; it++)
#define rtr(v,it) for( LET(it,v.rbegin()) ; it != v.rend() ; it++)
#define TC() int tc;cin >> tc; while(tc--)

/* Initialisation */

#define init(a,b) memset(a,b,sizeof(a))

/* Debugging */

#define echo(x) cerr << "It's fine at " << x << " position" << "\n";
#define TRACE
#ifdef TRACE
#define trace1(x)                cerr << #x << ": " << x << endl;
#define trace2(x, y)             cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
#define trace3(x, y, z)          cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl;
#define trace4(a, b, c, d)       cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << endl;
#define trace5(a, b, c, d, e)    cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << endl;
#define trace6(a, b, c, d, e, f) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << " | " << #f << ": " << f << endl;
#else
#define trace1(x)
#define trace2(x, y)
#define trace3(x, y, z)
#define trace4(a, b, c, d)
#define trace5(a, b, c, d, e)
#define trace6(a, b, c, d, e, f)
#endif

/* Finding */

#define ALL(a) a.begin(),a.end()
#define LB(a,x) (lower_bound(ALL(a),x)-a.begin())
#define UB(a,x) (upper_bound(ALL(a),x)-a.begin())

/* Exponentiation */

inline ll Pow(ll a, ll b, ll mod){ll res=1;while(b){if(b&1)res=(res*a)%mod;a=(a*a)%mod;b>>=1;}return res;}

/* Combinatorics */

// Method 1 ---->  To use in a function Uncomment next line and call Fact() once and then comb(a,b) when needed

#define LIM 10001
ll fact[LIM];
inline void Fact(){fact[0]=1;rep(i,1,LIM-1)fact[i]=(i*fact[i-1])%MOD;}
inline ll inv(ll x,ll mod){return Pow(x,mod-2,mod);}
inline ll comb(ll a, ll b){return ((fact[a]*inv(fact[b],MOD)%MOD)*inv(fact[a-b],MOD))%MOD;}

// Method 2 ----> To use in a function Uncomment next line and call COMB() once and then C[a][b] when needed

/*
#define LIM 5001
ll C[LIM][LIM];
inline void COMB(){rep(i,0,LIM-1){C[i][0]=C[i][i]=1;rep(j,1,i>>1)C[i][j]=C[i][i-j]=(C[i-1][j]+C[i-1][j-1])%MOD;}}
*/

/**********************************************************************************************************************************

  							Main Code

**********************************************************************************************************************************/
ll val[1001],dp[1001];
int main()
{
	SpeedUp;
	Fact();
	//COMB();
	ll k;
	cin >> k;
	rep(i,1,k)
		cin >> val[i];
	dp[1]=1;
	ll tot=0;
	rep(i,2,k)
	{
		tot+=val[i-1];
		ll b=val[i];
		dp[i]=(dp[i-1]*comb(b-1+tot,tot))%MOD;
	}
	cout << dp[k] << "\n";
	return 0;
}


/**********************************************************************************************************************************

						     Author  : Vivek Nynaru
   						     Handle  : kevin11

**********************************************************************************************************************************/

#include<bits/stdc++.h>
using namespace std;
#define SpeedUp std::ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

/* Typedef's for most frequently used DataTypes */

typedef long long int ll;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef set<int> si;
typedef map<int,int> mii;
typedef map<string,int> msi;
typedef priority_queue < ll , vector < ll > , greater < ll > > minheap;
typedef priority_queue < ll , vector < ll > , less < ll > > maxheap;

/* Most frequently used Constants */

#define INF 1000000000000000000
#define PI M_PI
#define E M_E
#define MOD 1000000007

/* Most frequently used Functions */

#define pb push_back
#define pp pop_back
#define mp make_pair
#define F first
#define S second

/* For variables */

#define LET(x,a) __typeof(a) x(a)

/* Iterations */

#define rep(i, a, b) for (int i = int(a);i <= int(b); i++)
#define rev(i, a, b) for (int i = int(b);i >= int(a); i--)
#define repi(i, a, b) for (int i = int(a);i < int(b); i++)
#define revi(i, a, b) for (int i = int(b);i > int(a); i--)
#define tr(v,it) for( LET(it,v.begin()) ; it != v.end() ; it++)
#define rtr(v,it) for( LET(it,v.rbegin()) ; it != v.rend() ; it++)
#define TC() int tc;cin >> tc; while(tc--)

/* Initialisation */

#define init(a,b) memset(a,b,sizeof(a))

/* Debugging */

#define echo(x) cerr << "It's fine at " << x << " position" << "\n";
#define TRACE
#ifdef TRACE
#define trace1(x)                cerr << #x << ": " << x << endl;
#define trace2(x, y)             cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
#define trace3(x, y, z)          cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl;
#define trace4(a, b, c, d)       cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << endl;
#define trace5(a, b, c, d, e)    cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << endl;
#define trace6(a, b, c, d, e, f) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << " | " << #f << ": " << f << endl;
#else
#define trace1(x)
#define trace2(x, y)
#define trace3(x, y, z)
#define trace4(a, b, c, d)
#define trace5(a, b, c, d, e)
#define trace6(a, b, c, d, e, f)
#endif

/* Finding */

#define ALL(a) a.begin(),a.end()
#define LB(a,x) (lower_bound(ALL(a),x)-a.begin())
#define UB(a,x) (upper_bound(ALL(a),x)-a.begin())

/* Exponentiation */

inline ll Pow(ll a, ll b, ll mod){ll res=1;while(b){if(b&1)res=(res*a)%mod;a=(a*a)%mod;b>>=1;}return res;}

/* Combinatorics */

// Method 1 ---->  To use in a function Uncomment next line and call Fact() once and then comb(a,b) when needed

/*
#define LIM 1000001
ll fact[LIM];
inline void Fact(){fact[0]=1;rep(i,1,LIM-1)fact[i]=(i*fact[i-1])%MOD;}
inline ll inv(ll x,ll mod){return Pow(x,mod-2,mod);}
inline ll comb(ll a, ll b){return ((fact[a]*inv(fact[b],MOD)%MOD)*inv(fact[a-b],MOD))%MOD;}
*/

// Method 2 ----> To use in a function Uncomment next line and call COMB() once and then C[a][b] when needed

#define LIM 5001
ll C[LIM][LIM];
inline void COMB(){rep(i,0,LIM-1){C[i][0]=C[i][i]=1;rep(j,1,i>>1)C[i][j]=C[i][i-j]=(C[i-1][j]+C[i-1][j-1])%MOD;}}

/**********************************************************************************************************************************

  							Main Code

**********************************************************************************************************************************/
ll val[1001],dp[1001];
int main()
{
	SpeedUp;
	//Fact();
	COMB();
	ll k;
	cin >> k;
	rep(i,1,k)
		cin >> val[i];
	dp[1]=1;
	ll tot=0;
	rep(i,2,k)
	{
		tot+=val[i-1];
		ll b=val[i];
		dp[i]=(dp[i-1]*C[b-1+tot][tot])%MOD;
	}
	cout << dp[k] << "\n";
	return 0;
}


#include <iostream>
#include <algorithm>
#include <cstdio>
#include <string.h>
#define MOD  1000000007
using namespace std;
long long ans;
int num[1005];
int k;
long long cal(int u,int w)
{
    if(w==0)
        return 1;
    double r=1;
    for(int i=w;i>=1;i--)
    {
        r*=(u+i);
        r/=i;
    }
    return r;
}
int main()
{
    int use=0;
    ans=1;
    memset(num,0,sizeof(num));
    scanf("%d",&k);
    for(int i=1;i<=k;i++)
        scanf("%d",&num[i]);
    use+=num[1];
    for(int i=2;i<=k;i++)
    {
        ans*=cal(use,num[i]-1);
        use+=num[i];
    }
    cout<<ans<<endl;
    return 0;
}


#include <iostream>
#include <algorithm>
#include <cstdio>
#include <string.h>
#include <cmath>
#define MOD 1000000007
using namespace std;

long long use[1050][1050];

int main()
{
    memset(use,0,sizeof(use));
    use[0][0]=1;
    for(int i=1;i<=1005;i++)
        for(int j=1;j<=i;j++)
         {
             use[i][0]=1;
             use[i][j]=(use[i-1][j-1]+use[i-1][j])%MOD;
         }
    int w;
    cin>>w;
    int num[1005];
    for(int i=1;i<=w;i++)
        cin>>num[i];
    long long ans=1;
    int u=num[1];
    for(int i=2;i<=w;i++)
    {
        ans*=use[u+num[i]-1][num[i]-1]%MOD;
        u+=num[i];
    }
    cout<<ans<<endl;
    return 0;
}


#include <iostream>
#include <algorithm>
#include <cstdio>
#include <string.h>
#include <cmath>
#define MOD 1000000007
using namespace std;

long long use[1050][1050];

int main()
{
    memset(use,0,sizeof(use));
    use[0][0]=1;
    for(int i=1;i<=1005;i++)
        for(int j=1;j<=i;j++)
         {
             use[i][0]=1;
             use[i][j]=(use[i-1][j-1]+use[i-1][j])%MOD;
         }
    int w;
    cin>>w;
    int num[1005];
    for(int i=1;i<=w;i++)
        cin>>num[i];
    long long ans=1;
    int u=0;
    for(int i=1;i<=w;i++)
    {
        ans=(ans*use[u+num[i]-1][num[i]-1])%MOD;
        u+=num[i];
    }
    cout<<ans<<endl;
    return 0;
}


#include <bits/stdc++.h>
#define mod 1000000007
#define MAX (1 << 10)

using namespace std;

int k;
long long a[MAX],s[MAX], f[MAX];

void I(){
    f[1] = f[0] = 1;
    for(int i=2; i<=1000; i++){
        f[i] = f[i-1] * i;
        f[i] %= mod;
    }
}

long long N(long long a, long long b){
    long long res = 1;
    while(b){
        if(b & 1) res = res * a % mod;
        a = a * a % mod;
        b >>= 1;
    }
    return res;
}

long long F(long long n, long long m){
    return (f[n]%mod * (N((f[m]*f[n-m])%mod, mod-2) % mod)) % mod;
}

int main(){
    //freopen("in.txt", "r", stdin);
    cin >> k;
    for(int i=1; i<=k; i++){
        cin >> a[i];
        s[i] = s[i-1] + a[i];
    }
    I();
    long long ans = 1;
    for(int i=k; i>=1; i--){
        //cout << s[i] - 1 << " " << a[i] - 1 << " " << F(s[i] - 1, a[i] - 1) << endl;
        ans *= F(s[i] - 1, a[i] - 1) % mod;
    }
    cout << ans << endl;
}


#include <bits/stdc++.h>
#define mod 1000000007
#define MAX (1 << 10)

using namespace std;

int k;
long long a[MAX],s[MAX], f[MAX];

void I(){
    f[1] = f[0] = 1;
    for(int i=2; i<=1000; i++){
        f[i] = f[i-1] * i;
        f[i] %= mod;
    }
}

long long N(long long a, long long b){
    long long res = 1;
    while(b){
        if(b & 1) res = res * a % mod;
        a = a * a % mod;
        b >>= 1;
    }
    return res;
}

long long F(long long n, long long m){
    return (f[n]%mod * (N((f[m]*f[n-m])%mod, mod-2) % mod)) % mod;
}

int main(){
    //freopen("in.txt", "r", stdin);
    cin >> k;
    for(int i=1; i<=k; i++){
        cin >> a[i];
        s[i] = s[i-1] + a[i];
    }
    I();
    long long ans = 1;
    for(int i=k; i>=1; i--){
        //cout << s[i] - 1 << " " << a[i] - 1 << " " << F(s[i] - 1, a[i] - 1) << endl;
        ans = (ans % mod * F(s[i] - 1, a[i] - 1) % mod) % mod;
    }
    cout << ans << endl;
}


#include <bits/stdc++.h>
#define mod 1000000007
#define MAX (1 << 10)

using namespace std;

int k;
long long a[MAX],s[MAX], f[MAX];

void I(){
    f[1] = 1;
    for(int i=2; i<=1000; i++){
        f[i] = f[i-1] * i;
        f[i] %= mod;
    }
}

long long N(long long a, long long b){
    long long res = 1;
    while(b){
        if(b & 1) res = res * a % mod;
        a = a * a % mod;
        b >>= 1;
    }
    return res;
}

long long F(long long n, long long m){
    return (f[n]%mod * (N((f[m]*f[n-m])%mod, mod-2) % mod)) % mod;
}

int main(){
    //freopen("in.txt", "r", stdin);
    cin >> k;
    for(int i=1; i<=k; i++){
        cin >> a[i];
        s[i] = s[i-1] + a[i];
    }
    I();
    long long ans = 1;
    for(int i=k; i>=2; i--){
        ans *= F(s[i] - 1, a[i] - 1);
    }
    cout << ans << endl;
}