#include<bits/stdc++.h>
#define ll long long
#define lld long long double
#define pb push_back
#define mp make_pair
#define M 1000000007
using namespace std;



int f(int n, int k, int a[]) {
	ll dp[n + 2][k + 2];
	for (int j = 0; j <= k; j++)
		dp[1][j] = (j > a[1]) ? 0 : 1;
	for (int i = 2; i <= n; i++) {
		for (int j = 0; j <= k; j++) {
			if (j == 0) dp[i][j] = dp[i - 1][j];
			else {
				dp[i][j] = (mod + dp[i][j - 1] + dp[i - 1][j] - ((j - a[i] - 1 >= 0) ? dp[i - 1][j - a[i] - 1] : 0)) % M;
			}
		}
	}
	return dp[n][k];
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
// #ifndef ONLINE_JUDGE
// 	freopen("input.txt", "r", stdin);
// 	freopen("output.txt", "w", stdout);
// #endif
	int n, k;
	cin >> n >> k;
	int a[n + 1];
	for (int i = 1; i <= n; i++) cin >> a[i];
	cout << f(n, k, a);
	return 0;
}