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

#define ll long long


// 4
//1 2 3

//1 0 3
//1 1 2
//1 2 1
//0 2 2
//0 1 3

ll subsetSum(int start, vector<int>& candies, int sum,
             vector<int>& p, vector<vector<ll>>& memo)
{
    if(sum == 0)
    {
        //        for(auto& e: p)
        //            cout << e << " ";
        //        cout << endl;
        return 1;
    }
    else if(sum < 0) return 0;


    ll n = 0;
    if(start >= candies.size())
        return 0;

    if(memo[start][sum] != -1)
        return memo[start][sum];

    for(int j = candies[start]; j >= 0; j--)
    {
        p.push_back(j);
        n += subsetSum(start+1, candies, sum-j, p, memo);
        p.pop_back();
    }


    memo[start][sum] = n;

    return n;
}

//dp[i][j] - num ways to setup sum i using j children
//dp[0][0] = 1
//dp[0][1] = 1, dp[0][2] = 1, ...
//dp[1][0] = 0, dp[2][0] = 0, ...
//dp[i][j] = sum k from 0 to c[j]: dp[i-k][j-1]

const ll MOD = 1e9 + 7;
int main()
{
    int N, K;
    cin >> N >> K;
    vector<int> candies;
    for(int i = 0; i < N; i++)
    {
        int candy;
        cin >> candy;
        candies.push_back(candy);
    }
    vector<int> p;
//    vector<vector<ll>> memo(candies.size(), vector<ll>(K+1, -1));
//    ll cnt = subsetSum(0, candies, K, p, memo);
//    cout << cnt << endl;

//    vector<vector<ll>> dp(K+1, vector<ll>(candies.size(), 0));
//    dp[0] = vector<ll>(candies.size(), 1);
//    for(int i = 1; i <= K; i++)
//    {
//        for(int j = 0; j < candies.size(); ++j)
//        {
//            if(j == 0)
//            {
//                dp[i][j] = candies[0] >= i ? 1 : 0;
//            }
//            else {
//            for(int k = 0; k <= min(i, candies[j]); k++)
//                dp[i][j] += dp[i-k][j-1];
//            }
//        }
//    }

    vector<vector<ll>> dp(candies.size()+1, vector<ll>(K+1, 0));
    for(int i = 0; i <= candies.size(); i++)
        dp[i][0] = 1;

    for(int i = 1; i <= candies.size(); i++)
    {
        for(int j = 1; j <= K; j++)
        {
//            if(i == 0)
//            {
//                dp[i][j] = j > candies[0] ? 0 : 1;
//            }
//            else
        ll s = (dp[i-1][j] % MOD + dp[i][j-1] % MOD);
        if(j-candies[i-1]-1 >= 0)
            dp[i][j] += (s - dp[i-1][j-candies[i-1]-1] + MOD) % MOD;
        else
            dp[i][j] += s % MOD;
//            for(int k = 0; k <= min(j, candies[i]); k++)
//                dp[i][j] += dp[i-1][j-k];
        }
    }

//    for(auto& v: dp)
//    {
//        for(auto& e: v)
//            cout << e << " ";
//        cout << endl;
//    }

    cout << dp[candies.size()][K] << endl;
//    cout << dp[K][candies.size()] << endl;


    return 0;
}

//i,j and express x -> (i+j) - x + 1
// 1, 2, 3, 4, 5, ...
//4,5 -> 9 (4+5), 8 (4+4, 3+5), 7 (3+4, 4+3, 2+5), 6 (3+3, 4+2, 2+4, 1+5), 5 (0+5, 1+4, 2+3, 3+2, 4+1),
// 4 (0+4, 1+3, 2+2, 3+1, 4+0, 3+1)

//1, 3, 5, 6, 5 3
//1,2,3 -> 6 (1+2+3), 5 (1+2+2, 1+1+3, 0+2+3), 4 (0+2+2, 0+1+3, 1+0+3, 1+1+2, 1+2+1),
//3 (0+0+3, 0+1+2, 0+2+1, 1+0+2, 1+1+1, 1+2+0), 2 (0+0+2, 0+1+1, 0+2+0, 1+0+1, 1+1+0), 1 (1+0+0, 0+1+0, 0+0+1)

//1,2,3,4 -> 10 (1+2+3+4), 9 ()

//dp[i][j] = dp[i][j-1] + C(j-1, 1) + (C(j-1, 1) + C(j-1, 2)) + (C(j-1,1) + 2 * C(j-1, 2) + C(j-1,3)) +
//(C(j-1, 1) + )


Measured memory_bytes: 80256