#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
typedef long long ll;
  int main(){
  ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
  ll n,k;
  cin>>n>>k;
    ll a[n];
    for(int i=0;i<n;i++)
      cin>>a[i];
  ll dp[n][k+1];
    memset(dp,0,sizeof(dp));
   for(int i=0;i<=a[n-1];i++)
     dp[n-1][i]=1;
    for(int i=0;i<n;i++)
      dp[i][0]=1;
    for(int i=n-2;i>=0;i--){
      for(int j=1;j<=a[i];j++)
        dp[i][j]=(dp[i][j-1]+dp[i+1][j])%mod;
      for(int j=a[i]+1;j<=k;j++)
        dp[i][j]=(dp[i][j-1]+dp[i+1][j]-dp[i+1][j-a[i]-1])%mod;
      if(dp[i][j]<0)
        dp[i][j]+=mod;
     }
                  cout<<dp[0][k]<<"\n";
  return 0;
}