//#include<cstdio>
//#include<cstdlib>
#include <iostream>
#include <vector>
#include <queue>
//#include<bitset>
//#include<string>
//#include<stack>
//#include<set>
//#include<unordered_set>
//#include<map>
//#include<unordered_map>
//#include<cstring>
//#include<complex>
//#include<cmath>
//#include<iomanip>
//#include<numeric>
#include <algorithm>
#include <stdio.h>
//#include<list>
//#include<functional>
//#include<cassert>
using namespace std;
#define ll long long int
#define llu unsigned long long int
#define m 1000000007
void pv(vector<ll> arr, ll size)
{

    for (ll i = 0; i < size; i++)
    {
        cout << arr[i] << ' ';
    }
}
void gv(vector<ll> &arr)
{
    ll size = arr.size();
    for (ll i = 0; i < size; i++)
    {
        cin >> arr[i];
    }
}
int main(void)
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll n, k;
    cin >> n >> k;
    vector<ll> a(n);
    gv(a);
    ll arr[n + 1][k + 1] = {0};
    for (ll i = n; i > 0; i--)
    {
        ll cum[k + 1] = {0};
        if (i != n)
        {
            cum[0] = arr[i + 1][0];
            for (ll w = 1; w <= k; w++)
            {
                cum[w] = (cum[w - 1] + arr[i + 1][w]) % m;
            }
            // for (ll w = 0; w < k; w++)
            //     cout << cum[w] << " ";
            // cout << '\n';
        }
        ll cc = 0;
        for (ll j = 0; j <= k; j++)
        {
            if (i == n)
            {
                if (j > a[i - 1])
                    arr[i][j] = 0;
                else
                    arr[i][j] = 1;
            }
            else
            {
                // ll cum[k + 1];
                if (j == 0)
                {
                    arr[i][j] = 1;
                }
                else if (j > a[i - 1])
                {
                    arr[i][j] = cum[j] - cum[cc];
                    cc++;
                }
                else
                {
                    arr[i][j] = cum[j];
                }
            }
            // cout << arr[i][j] << " ";
        }
        // cout << '\n';
    }
    cout << arr[1][k];
    return 0;
}