#include<bits/stdc++.h>
using namespace std;
#define ld double
#define lli long long int
#define vi vector<int>
#define vlli vector<lli>
#define vvi vector<vi >
#define str string
#define vs vector<str>
#define vb vector<bool>
#define mii map<int, int>
#define mp make_pair
#define mod 1000000007
#define pii pair<int, int>
#define vpii vector<pii >
#define pb push_back
#define loop(i, s, l, j) for(int i = s; i < l; i += j)
#define rloop(i, s, l, j) for(int i = s; i >= l; i -= j)
#define fastio() ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#define limit 100005
#define ft first
#define sd second
#define maxval 8.0
#define pi 3.14159265358979323846
int dx[4] = {0, 0, -1, 1};//u d l r
int dy[4] = {1, -1, 0, 0};
/****************************************************************************/

int main()
{
   int n, K;
   cin >> n >> K;
   int a[n+1];
   for(int i = 1; i < n+1; i++)
     cin >> a[i];         
 
   int dp[n+1][K+1] = {};
   for(int j = 0; j < K+1; j++)
      dp[0][j] = 1;
   /*
   dp[0][0] = 1;
   for(int i = 1; i < n+1; i++)
      for(int j = 0; j < K+1; j++)
          for(int k = 0; k < min(a[i], j)+1; k++)
                     dp[i][j] += dp[i-1][j-k];
   */   
   for(int i = 1; i < n+1; i++)
   {
      for(int j = 0; j < K+1; j++)
      {
          int k = j-min(a[i], j);
          dp[i][j] = dp[i-1][j]-(k==0?0:dp[i-1][k-1]);
      }
      for(int j = 1; j < K+1; j++)
         dp[i][j] = (dp[i][j] + dp[i][j-1])%mod;
  }

  cout << (dp[n][K]-(K==0?0:dp[n][K-1])) << '\n';

}