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

const int mod=1e9+7;

void add_self(auto &a,auto b)
{
a+=b;
if(a>=mod)a-=mod;
}
int main()
{
int n,k;
cin>>n>>k;
vector<long long>dp(k+1,0);//z(k+1,0);
//dp[k]=1;
dp[0]=1;
for(int i=0;i<n;i++)
{
int up_to;
cin>>up_to;
vector<long long>temp(k+1,0);
for(int j=k;j>=0;j--)
{
if(j<k){
add_self(temp[j+1],dp[j]);
if(j+min(up_to,k-j)+1<=k){
add_self(temp[j+min(up_to,k-j)+1],-dp[j]);}
}

}
long long q=0;
for(int i=0;i<=k;i++){add_self(q,temp[i]);add_self(dp[i],q);}
}

cout<<dp[k];
}