#include "bits/stdc++.h"
using namespace std;
#define sim template <class c
#define ris return *this
#define dor > debug &operator<<
#define eni(x)                                                                    \
    sim > typename enable_if<sizeof dud<c>(0) x 1, debug &>::type operator<<(c i) \
    {
sim > struct rge
{
    c b, e;
};
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c *x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug
{
#ifdef LOCAL
    ~debug()
    {
        cerr << endl;
    }
    eni(!=) cerr << boolalpha << i;
    ris;
} eni(==) ris << range(begin(i), end(i));
}
sim, class b dor(pair<b, c> d)
{
    ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d)
{
    *this << "[";
    for (auto it = d.b; it != d.e; ++it)
        *this << ", " + 2 * (it == d.b) << *it;
    ris << "]";
}
#else
    sim dor(const c &)
    {
        ris;
    }
#endif
}
;
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

const int MOD = 1e9 + 7;
const int N = int(3e5) + 999;
//#define int long long int
#define inf 1e18

int n, k;
void add(int &a, int b)
{
    a = a + b;
    if (a >= MOD)
        a -= MOD;
}

void sub(int &a, int b)
{
    a = a - b;
    if (a < 0)
        a += MOD;
}

int main()
{
    cin >> n >> k;
    vector<int> dp(k + 1, 0);
    dp[0] = 1;
    for (int i = 0; i < n; i++)
    {
        int lmt;
        cin >> lmt;
        for (int used = k; used >= 0; used--)
        {
            int tmp = dp[used];
            vector<int> fake(k + 1, 0);
            int l = used + 1;
            int r = used + min(lmt, k - used);
            if (l <= r)
            {
                add(fake[l], tmp);
                if (r + 1 <= k)
                    sub(fake[r + 1], tmp);
            }
        }
        int pp = 0;
        for (int i = 0; i <= k; i++)
        {
            add(pp, fake[i]);
            add(dp[i], pp);
        }
    }
    cout << dp[k];

    return 0;
}