#include <bits/stdc++.h>
using namespace std;

int main(void)
{
    int N, K;
    cin >> N >> K;

    int dp[N+1][K+1] = {};

    vector<int> a(N+1,0);

    for (int i = 1; i <= N; ++i)
    {
        int tmp;
        cin >> tmp;
        a.at(i) = tmp;
    }

    for (int i = 0; i <= N; ++i)
    {
        dp[i][0] = 1;
    }

    for (int i = 1; i <= N; ++i)
    {
        for (int j = 1; j <= K; ++j)
        {
            dp[i][j] = (dp[i][j] + dp[i-1][j] + dp[i][j-1]) % 1000000007;
            if(j-a.at(i)-1 >= 0) dp[i][j] = (dp[i][j] - dp[i-1][i-a.at(i)-1]) % 1000000007;
            // for(int l = 0; l <= a.at(i); ++l)
            // {
            //     if(j-l >= 0) dp[i][j] = (dp[i][j] + dp[i-1][j-l]) % 1000000007;
            // }
        }
    }

    cout << dp[N][K] << endl;

    return 0;
}

