#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>

int main(){
    using namespace std;
    constexpr unsigned int MOD = 1000000007;
    unsigned long N, K;
    cin >> N >> K;
    vector<unsigned int> dp(K + 1);
    dp[0] = 1;
    for(unsigned long i{0}, a; i < N; ++i){
        cin >> a;
        for(unsigned long j{K}; j > a; --j)dp[j] += dp[j] > dp[j - a - 1] ? -dp[j - a - 1] : MOD - dp[j - a - 1];
    }
    for(unsigned long i{0}; i < N; ++i)partial_sum(dp.begin(), dp.end(), dp.begin(), [](auto i, auto j){return (i + j) % MOD;});
    cout << dp.back() << endl;
    return 0;
}