//@author yash2040
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define int long long
#define pb push_back
#define mod 1000000007
#define fast() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
main()
{
//	fast();
 	int n, B;
    cin>>B>>n;
    vector<int> dp(B+1);
    // dp[i] - the number of ways such that we allocated i beds so far.
    dp[0]=1;
    for(int states=0;states<n;states++) 
	{
        int req;
        cin>>req;
        vector<int> pref(B+1,0);
        //For each state,we consider the number of beds allocated so far(used).
        for(int used=B;used>=0;used--) 
		{
            int tmp = dp[used];
            //Each state can take minimum 0 beds and maximum req beds
            int L = used+1;//We allocate 1 bed
            int R = used+min(req,B-used);//Or we allocate the number of beds equal to req taking into account beds remaining 
            
            /*for(int i=L;i<=R;i++) 
			{
                dp[i]=(dp[i]%mod+tmp%mod)%mod;
            }*/
            
            int sum = 0;
        	for(int i=0;i<=B;i++)
			{
				sum=sum%mod+pref[i]%mod;
				dp[i]=dp[i]%mod+sum%mod;
        	}
        }
        
    }
    //final answer is dp[k].
    cout<<dp[B]%mod;
}