#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;
using namespace std;
#define int      long long int
#define MOD      1000000007
#define pb       push_back
#define pf		 push_front
#define vi       vector<int>
#define mi  	 map<int,int>
#define umi		 unordered_map<int,int>
#define pii      pair<int,int>
#define ff 		 first
#define ss 		 second
#define inf		 1e18
#define case	int t;cin>>t;while(t--)
//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
void pre()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
}
int dp[100003][102];
int32_t main()
{	pre();
	//case
	{	int n , k;
		cin >> n >> k;
		int a[n], sm[n] = {0};
		for (int i = 0; i < n; i++)
		{	cin >> a[i];
			sm[i] = a[i];
			if (i != 0)
				sm[i] += sm[i - 1];
			sm[i] %= MOD;
		}
		for (int i = 0; i <= k; i++)
		{	if (a[0] >= i)
				dp[i][0] = 1;
			else
				dp[i][0] = 0;
		}
		for (int i = 0; i <= k; i++)
		{	for (int j = 1; j < n; j++)
			{	if (i == 0)
					dp[i][j] = 1;
				else if (sm[j] < k || dp[i - 1][j] == 0)
					dp[i][j] = 0;
				else if (sm[j - 1] < k)
					dp[i][j] = (dp[i - 1][j] - j + sm[j - 1] + MOD ) % MOD ;
				else
					dp[i][j] = (dp[i - 1][j] + dp[i][j - 1]) % MOD;

				dp[i][j] %= MOD;

			}
		}
		//	for (int i = 0; i <= k; i++)
		//	{	for (int j = 0; j < n; j++)
		//			cout << dp[i][j] << " ";
		//		cout << endl;
		//	}
		cout << dp[k][n - 1];
	}
	return 0;
}
