#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <assert.h>
#include <numeric>
#include <math.h>
#include <climits>
#include <stack>
#include <iomanip>
#include <sstream>

using namespace std;

template <typename T>
inline bool sign(T A) {
    return (A>0)-(A<0);
}

#define REP(i,s,n) for(int i=s; (n-i)*sign(n-s)>0; i+=sign(n-s))
#define all(x) (x).begin(),(x).end()
typedef long long ll;
typedef unsigned long long ull;

template <typename T>
T gcd(T a, T b) {
    if(a < b) gcd(b, a);
    if (b == 1) return 1;
    T r;
    while ((r=a%b)) {
        a = b;
        b = r;
    }
    return b;
}

#define MOD (1'000'000'000+7)

bool _less(pair<int, int> a, pair<int, int> b) {
    return a.second < b.second;
}

template <template<class,class,class...> class C, typename K, typename V, typename... Args>
V map_get(const C<K,V,Args...>& m, K const& key, const V & defval)
{
    typename C<K,V,Args...>::const_iterator it = m.find( key );
    if (it == m.end())
        return defval;
    return it->second;
}

int dp[100001][101];

int main() {
    int N, K;
    cin >> N >> K;
    vector<int> a(N+1);
    REP(i, 0, N) {
        cin >> a[i+1];
    }

    int suma = 0;
    REP(j, 1, N+1) {
        suma += a[j];
        dp[0][j] = 1;
        dp[1][j] = j;
        REP(i, 2, min(suma+1, K+1)) {
            dp[i][j] = (dp[i-1][j] - (i-a[j]-1>=0?dp[i-a[j]-1][j-1]:0) + dp[i][j-1])%MOD;
        }
    }
    
    cout << dp[K][N] << endl;
}
