#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
#include <ext/pb_ds/detail/standard_policies.hpp>

using namespace std;
using namespace __gnu_pbds;

typedef tree<int, null_type, less<int>, rb_tree_tag,
		tree_order_statistics_node_update> ordered_set;

#define el				'\n'
#define sz(v)			((int)((v).size()))
#define all(v)          ((v).begin()),((v).end())
#define clr(v, d)		memset(v, d, sizeof(v))

double const EPS = 1e-8, PI = acos(-1);
const int N = 100 + 9, M = 1e5 + 9, OO = (int) 1e9 + 1;
const long long MOD = 1e9 + 7, INF = 1e18 + 9;

typedef long long ll;

void OUTPUT() {
	cout << fixed << setprecision(12);
	ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
}

void INPUT() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);
#endif
}

int n, s, k, x, dp[M], fake[M], temp, L, R;


int main() {
	//INPUT();
	OUTPUT();
	cin >> n >> k;
	dp[0] = 1;
	for (int child = 0; child < n; child++) {
		cin >> x;
		clr(fake, 0);
		for (int used = k; used >= 0; --used) {
			temp = dp[used];
			L = used + 1;
			R = used + min(x, k - used);
			if (L <= R) {
				fake[L] = (fake[L] + temp) % MOD;
				if (R + 1 <= k) {
					fake[R + 1] = ((fake[R + 1] - temp)) + MOD % MOD;
				}
			}
		}
//		cout << child << " " << s << endl;
		s = 0;

		for (int i = 0; i <= k; ++i) {
			s = (s + fake[i]) % MOD;
			dp[i] = (dp[i] + s) % MOD;
		}

	}
	cout << dp[k];

	return 0;

}
