#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
#define mod 1000000007

int main(){
    int n,k;
    cin>>n>>k;
    int i,j,l;
    int a[n+1];
    for(i=1;i<=n;i++) cin>>a[i];
    int dp[n+1][k+1];
    for(i=0;i<=n;i++){
        for(j=0;j<=k;j++){
            dp[i][j]=0;
        }
    }
    dp[0][0]=1;
    lli x[k+1]={0};
    for(i=1;i<=n;i++){
        for(j=0;j<=k;j++){
            if(j==0) x[j]=dp[i-1][j];
            else x[j]=x[j-1]+dp[i-1][j];
            x[j]%=mod;
        }
        /*for(j=0;j<=k;j++){
            for(l=0;l<=a[i] && j-l>=0;l++){
                dp[i][j]+=dp[i-1][j-l];
            }
        }*/
        for(j=0;j<=k;j++){
            if(j>a[i])
            dp[i][j]=dp[i][j] + (x[j] - x[j-a[i]-1])%mod;
            else
            dp[i][j]=dp[i][j] + x[j];
            
            dp[i][j]%=mod;
        }
    }
    cout<<dp[n][k]<<endl;
    return 0;
}