#include <bits/stdc++.h>
 
using namespace std;
 
const int N = 3e3 + 10;
const int MOD = 1e9 + 7;
 
typedef long long ll;
int main() {
    int n, k;
    cin >> n >> k;
    vector<ll> f(k + 1, 1);
    while (n--) {
        int use;
        cin >> use;
        for(int i = k; i >= 0; i--) {
            f[i] -= (i - use - 1 >= 0 ? f[i - use - 1] : 0);
        }
        for(int i = 1; i <= k; i++)
            f[i] = (f[i] + f[i - 1] + 2LL * MOD) % MOD;
    }
    ll ans = f[k];
    if (k > 0) ans = (ans - f[k - 1] + MOD) % MOD;
    cout << ans;
}
