#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define pf push_front
#define mt make_tuple
#define popb pop_back
#define popf pop_front
#define int long long int
#define vi         vector<int>
#define vll        vector<ll>
#define vpii       vector<pair<int,int>>
#define vpll       vector<pair<ll,ll>>
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define sz(container) int((container).size())
#define rep(i,a,b) for(i=a;i<b;i++)
#define tr(container,it)   for(auto it = container.begin(); it != container.end(); it++)
#define present(container, element) (container.find(element) != container.end())      //set,map etc.
#define cpresent(container, element) (find(all(container),element) != container.end())    //vector
#define hell 1000000007
#define PI 3.14159265
#define mod 998244353
#define fs first
#define sc second
#define TIME        cerr << "\nTime elapsed: " << setprecision(5) <<1000.0 * clock() / CLOCKS_PER_SEC << "ms\n";
void solve()
{
  int n,k,i,j;
  cin>>n>>k;
  int a[n];
  rep(i,0,n)cin>>a[i];
  int dp[n][k+1], p[n][k+1];
  for(i=0;i<n;i++)
  {
    for(j=0;j<=k;j++)
      p[i][j]=0;
  }
  for(i=0;i<n;i++)
  {
      dp[i][0]=1;
      p[i][0]=1;
  }
  for(j=0;j<=k;j++)
  {
    if(j<=a[0])
      dp[0][j]=1;
    else
      dp[0][j]=0;
  }
  for(j=1;j<=k;j++)
  {
    p[0][j]=p[0][j-1]+dp[0][j];
    p[0][j]%=hell;
  }
  /*for(i=0;i<n;i++)
  {
    for(j=0;j<=k;j++)
    {
      cout<<dp[i][j]<<" ";
    }
    cout<<endl;
  }*/ 
  for(i=1;i<n;i++)
  {
    for(j=1;j<=k;j++)
     {
       int l=j-a[i];
       if(l<0)
        l=0;
       if(l==0)
        dp[i][j]= p[i-1][j]%hell;
       else
        dp[i][j]= (p[i-1][j]-p[i-1][l-1])%hell;
       p[i][j]=(p[i][j-1]+dp[i][j])%hell;   
     }
  }
  cout<<dp[n-1][k]%hell;
}
signed main()
{
  fastio
  //freopen("input.txt", "r", stdin);
  //freopen("output.txt", "w", stdout);
  int t;
  t=1;
  //cin>>t;
  while(t--)
  solve();
  TIME
  return 0;
}