 #include<iostream>
#include<cmath>
#include<unordered_map>
#include<math.h>
#include<vector>
#include<queue>
#include<set>
#include<algorithm>
#include<iomanip>
#include<string>
#include<map>
#define PI 3.14159265
#define mod 998244353  
#define mod1 1000000007  
using namespace std;

// A Dynamic Programming based solution to compute nCr % p 


// Returns nCr % p 
int nCrModp(long long n, long long r, long long p) 
{ 
	// Optimization for the cases when r is large 
	if (r > n - r) 
		r = n - r; 

	// The array C is going to store last row of 
	// pascal triangle at the end. And last entry 
	// of last row is nCr 
	long long C[r + 1] = {0}; 
	  

	C[0] = 1; // Top row of Pascal Triangle 

	// One by constructs remaining rows of Pascal 
	// Triangle from top to bottom 
	for (int i = 1; i <= n; i++) { 

		// Fill entries of current row using previous 
		// row values 
		for (int j = min((long long)(i), r); j > 0; j--) 

			// nCj = (n-1)Cj + (n-1)C(j-1); 
			C[j] = (C[j] + C[j - 1]) % p; 
	} 
	return C[r]; 
} 


void func(){
    long long n , k ;
    cin >> n >> k ;
    //k is the total chocos and n is total no. of student.
     
    long long ans =  nCrModp((n + k - 1) , k , mod1) , arr[n];
    //cout << ans << " ";
    for(int i = 0 ; i < n ; ++i){
         scanf("%ld" , &arr[i]);
    }
    long long sum = 0;
    for(int i = 0 ; i < n; ++i){
       // cout << (n + k - 1 - arr[i]) << " " << k - arr[i] << "\n";
        if(arr[i] == k){
            continue;
        }
        else
         sum += nCrModp((n + k - 2 - arr[i]) , k - 1 - arr[i] , mod1);
    }

   
     printf("%ld" , (ans - sum) % mod1);
}   

int main(){
int t = 1 , cnt = 0 ;
//cin >> t;

while(t--){  
    func();
}
}