#include <bits/stdc++.h>
 
using namespace std;
 
//#define PRAGMA 448
#ifdef PRAGMA
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#endif
 
#ifdef LUCARIO
#define deb(...) fprintf(stderr,__VA_ARGS__)
#define deb1(x) cerr << #x << " = " << x << endl
#else
#define deb(...) 0
#define deb1(x) 0
#endif
 
typedef pair<long long,long long> pll;
typedef pair<int,int> pii;

#define FIN ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
#define ld long double
#define int long long
#define pb push_back
#define bs binary_search
#define up upper_bound
#define f first 
#define s second 
#define ff first.first
#define fs first.second
#define sf second.first
#define ss second.second
#define mp make_pair    
#define endl "\n"
 
#define fore(i,a,b) for(ll i = a; i < b; i++)
#define rfore(i, a, b) for(ll i = b - 1; i >= a; i--)
#define forev(a,b) fore(i,0,b)cout<<a[i]<<" "; 
#define ing(g,u,v)  g[u].pb(v); g[v].pb(u);
#define ingp(g,u,v,c) (g[u].pb({v,c});g[v].pb({u,c});)
#define mm(a,b) memset(a , b , sizeof a) 
#define trans(a,b) trasform(a.begin(),a.end(),a.begin(),b)
#define ALL(a) a.begin(),a.end() 
#define SZ(n) ((ll) (n).size())
#define sfind(s,t) (s.find(t) != string::npos)
 
#define infll (ll)1e15
#define infi  (int)(1e9+1)
#define PI 3.14159265359 
#define mod (ll)(1e9+7)
#define eps  1e-10

ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b,a%b); } 
ll lcm(ll a, ll b) { return a * (b / gcd(a, b)); }

#define MAXN 100100

int ft[MAXN +1]; // for more dimensions, make ft multi-dimensional
void upd(int i0, int v){ // add v to i0th element (0-based)
        // add extra fors for more dimensions
        for(int i=i0+1;i<=MAXN;i+=i&-i)ft[i]= (ft[i] + v)%mod;
}
int get(int i0){ // get sum of range [0,i0)
        int r=0;
        // add extra fors for more dimensions
        for(int i=i0;i;i-=i&-i)r= (r +ft[i])%mod;;
        return r;
}
int get_sum(int i0, int i1){ // get sum of range [i0,i1) (0-based)
        return (get(i1)-get(i0)+mod)%mod;
}
int a[101];
int dp[100001][2];

int32_t main(int32_t argc, char const *argv[]){
    FIN;

    int n ,k;cin>>n>>k;
    fore(i,0,n)cin>>a[i];
    bool b = true;
    fore(i,0,a[n-1]+1){
        dp[i][b] =1;
        upd(i,1);
    }

    rfore(i,0,n-1){
        b = !b;
        fore(j,0,k+1){
            dp[j][b] = get_sum(max(j-a[i],0ll),j+1);
         //   cout<<dp[j][b]<<" ";
        }
        mm(ft,0);
        fore(j,0,k+1){
            upd(j,dp[j][b]);
        }
    }
    cout<<dp[k][b];


    return 0;
}







































































































































































































































































































































































//formulas 
//cero = r/k  -(l/k + (l%k!=0)) +1; cantidad de numeros divisibles por k en el intervalo [l r]
//upper_bound primer elemento mayot estricto
//lower_bound primer elemento mayo o igual
//al hacer bfs con distancia recordar simpre antes de visitar preguntar si ya llegue antes co
//un peso menor
//setprecision(15)




//PROGRAMADO POR xXLucarioXx    


Measured memory_bytes: 2560