#include <bits/stdc++.h>
#define int long long
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define sz(x) (int)(x).size()
using namespace std;
const double pi = acos(-1);
const int mod = 1e9 + 7;
const int N = 1e2 + 5, M = 1e2 + 2, K = 1e5 + 5;
int dx[] = {0, 0, 1, -1, 1, 1, -1, -1};
int dy[] = {1, -1, 0, 0, 1, -1, 1, -1};
void fast()
{
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
ios::sync_with_stdio(false);
cin.tie(nullptr), cout.tie(nullptr);
}
int n, k;
int arr[N], dp[N][K];
int sol(int i, int rem)
{
if (i == n)
return (rem > 0 || rem < 0 ? 0 : 1);
if (rem == 0)
return 1;
if (rem < 0)
return 0;
int &ret = dp[i][rem];
if (~ret)
return ret;
ret = 0;
for (int j = 0; j <= arr[i]; j++)
ret += sol(i + 1, rem - j);
return ret;
}
int32_t main()
{
fast();
cin >> n >> k;
for (int i = 1; i <= n; i++)
cin >> arr[i];
if (n == 1)
{
cout << (arr[1] >= k);
return 0;
}
memset(dp, 0, sizeof dp);
dp[1][0] = 1;
for (int i = 0; i <= arr[1]; i++)
dp[1][i] = 1;
for (int i = 1; i <= k; i++)
dp[1][i] += dp[1][i - 1];
for (int i = 2; i <= n; i++)
{
for (int j = 0; j <= k; j++)
{
if (j <= arr[i])
(dp[i][j] += dp[i - 1][j]) %= mod;
else
(dp[i][j] += dp[i - 1][j] - dp[i - 1][j - arr[i] - 1]) %= mod;
}
if (i != n)
for (int j = 1; j <= k; j++)
{
dp[i][j] += dp[i][j - 1];
dp[i][j] %= mod;
}
}
cout << dp[n][k] % mod;
return 0;
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CiNkZWZpbmUgaW50IGxvbmcgbG9uZwojZGVmaW5lIGFsbCh4KSB4LmJlZ2luKCksIHguZW5kKCkKI2RlZmluZSByYWxsKHgpIHgucmJlZ2luKCksIHgucmVuZCgpCiNkZWZpbmUgc3ooeCkgKGludCkoeCkuc2l6ZSgpCgp1c2luZyBuYW1lc3BhY2Ugc3RkOwpjb25zdCBkb3VibGUgcGkgPSBhY29zKC0xKTsKY29uc3QgaW50IG1vZCA9IDFlOSArIDc7CmNvbnN0IGludCBOID0gMWUyICsgNSwgTSA9IDFlMiArIDIsIEsgPSAxZTUgKyA1OwoKaW50IGR4W10gPSB7MCwgMCwgMSwgLTEsIDEsIDEsIC0xLCAtMX07CmludCBkeVtdID0gezEsIC0xLCAwLCAwLCAxLCAtMSwgMSwgLTF9OwoKdm9pZCBmYXN0KCkKewojaWZuZGVmIE9OTElORV9KVURHRQogICAgZnJlb3BlbigiaW5wdXQudHh0IiwgInIiLCBzdGRpbik7CiAgICBmcmVvcGVuKCJvdXRwdXQudHh0IiwgInciLCBzdGRvdXQpOwojZW5kaWYKICAgIGlvczo6c3luY193aXRoX3N0ZGlvKGZhbHNlKTsKICAgIGNpbi50aWUobnVsbHB0ciksIGNvdXQudGllKG51bGxwdHIpOwp9CgppbnQgbiwgazsKaW50IGFycltOXSwgZHBbTl1bS107CgppbnQgc29sKGludCBpLCBpbnQgcmVtKQp7CiAgICBpZiAoaSA9PSBuKQogICAgICAgIHJldHVybiAocmVtID4gMCB8fCByZW0gPCAwID8gMCA6IDEpOwoKICAgIGlmIChyZW0gPT0gMCkKICAgICAgICByZXR1cm4gMTsKICAgIGlmIChyZW0gPCAwKQogICAgICAgIHJldHVybiAwOwoKICAgIGludCAmcmV0ID0gZHBbaV1bcmVtXTsKCiAgICBpZiAofnJldCkKICAgICAgICByZXR1cm4gcmV0OwoKICAgIHJldCA9IDA7CiAgICBmb3IgKGludCBqID0gMDsgaiA8PSBhcnJbaV07IGorKykKICAgICAgICByZXQgKz0gc29sKGkgKyAxLCByZW0gLSBqKTsKICAgIHJldHVybiByZXQ7Cn0KCmludDMyX3QgbWFpbigpCnsKICAgIGZhc3QoKTsKCiAgICBjaW4gPj4gbiA+PiBrOwoKICAgIGZvciAoaW50IGkgPSAxOyBpIDw9IG47IGkrKykKICAgICAgICBjaW4gPj4gYXJyW2ldOwoKICAgIGlmIChuID09IDEpCiAgICB7CiAgICAgICAgY291dCA8PCAoYXJyWzFdID49IGspOwogICAgICAgIHJldHVybiAwOwogICAgfQoKICAgIG1lbXNldChkcCwgMCwgc2l6ZW9mIGRwKTsKCiAgICBkcFsxXVswXSA9IDE7CiAgICBmb3IgKGludCBpID0gMDsgaSA8PSBhcnJbMV07IGkrKykKICAgICAgICBkcFsxXVtpXSA9IDE7CgogICAgZm9yIChpbnQgaSA9IDE7IGkgPD0gazsgaSsrKQogICAgICAgIGRwWzFdW2ldICs9IGRwWzFdW2kgLSAxXTsKCiAgICBmb3IgKGludCBpID0gMjsgaSA8PSBuOyBpKyspCiAgICB7CiAgICAgICAgZm9yIChpbnQgaiA9IDA7IGogPD0gazsgaisrKQogICAgICAgIHsKICAgICAgICAgICAgaWYgKGogPD0gYXJyW2ldKQogICAgICAgICAgICAgICAgKGRwW2ldW2pdICs9IGRwW2kgLSAxXVtqXSkgJT0gbW9kOwogICAgICAgICAgICBlbHNlCiAgICAgICAgICAgICAgICAoZHBbaV1bal0gKz0gZHBbaSAtIDFdW2pdIC0gZHBbaSAtIDFdW2ogLSBhcnJbaV0gLSAxXSkgJT0gbW9kOwogICAgICAgIH0KCiAgICAgICAgaWYgKGkgIT0gbikKICAgICAgICAgICAgZm9yIChpbnQgaiA9IDE7IGogPD0gazsgaisrKQogICAgICAgICAgICB7CiAgICAgICAgICAgICAgICBkcFtpXVtqXSArPSBkcFtpXVtqIC0gMV07CiAgICAgICAgICAgICAgICBkcFtpXVtqXSAlPSBtb2Q7CiAgICAgICAgICAgIH0KICAgIH0KCiAgICBjb3V0IDw8IGRwW25dW2tdICUgbW9kOwoKICAgIHJldHVybiAwOwp9