#include <bits/stdc++.h>
using namespace std;
int mod = 1e9 + 7;

void add_self(int &a, int b)
{
  a += b;
  if(a > mod) a -= mod;
}

void sub_self(int &a, int b)
{
  a -= b;
  if(a < 0) a += mod;
}

int main()
{
  int n, k;
  cin >> n >> k;
  int arr[n];
  for(int i = 0; i < n; i++) cin >> arr[i];
  int dp[k+1];
  vector<int>dp2(k+1);
  vector<int>fake(k+1);
  dp[0] = 1;
  for(int i = 0; i < n;i++)
  {
    for(int j = k; j >= 0; j--)
    {
      int temp = dp[j]
      int lb = j+1;
      int ub = j + min(k - j, arr[i]);
      if( lb <= ub){
        add_self(fake[lb], tmp);
        if ( ub + 1 <= k) sub_self(fake[ub+1], tmp);
      }
    }
  }
  int sm = 0;
  for(int i = 0; i <= k; i++)
  {
    add_self(sm, fake[i]);
    add_self(dp[i], sm);
  }
  cout << dp[k] << endl;
}
      
      
      
    